QIconPicker v1.4.3
Quasar v1.16.0

QIconPicker is an icon picker for your Quasar application. It allows you to have an icon selector embedded in your app. It uses a Quasar Icon Set or you can pass in an array of objects defining the icons to be displayed.

App Extension

Install

To add as an App Extension to your Quasar application, run the following (in your Quasar app folder):

quasar ext add @quasar/qiconpicker

Uninstall

To remove as an App Extension from your Quasar application, run the following (in your Quasar app folder):

quasar ext remove @quasar/qiconpicker

Describe

When installed as an App Extension, you can use quasar describe QIconPicker

OR:

Create and register a boot file:

1
2
3
4
5
import Vue from 'vue'
import Plugin from '@quasar/quasar-ui-qiconpicker'
import '@quasar/quasar-ui-qiconpicker/dist/index.css'

Vue.use(Plugin)

OR:

1
2
3
4
5
6
7
8
9
10
11
<style src="@quasar/quasar-ui-qiconpicker/dist/index.css"></style>

<script>
import { Component as QIconPicker } from '@quasar/quasar-ui-qiconpicker'

export default {
  components: {
    QIconPicker
  }
}
</script>

If you are using a large icon set and find it is taking too long to load, you can pre-cache the UMD variant.

You can do this by adding to your App.vue (or, any other appropriate) file, one or more of the UMD icon-set variants:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<template>
  <div id="q-app">
    <router-view />
  </div>
</template>

<script>
import '@quasar/quasar-ui-qiconpicker/dist/icon-set/eva-icons.umd.js'
import '@quasar/quasar-ui-qiconpicker/dist/icon-set/fontawesome-v5.umd.js'
import '@quasar/quasar-ui-qiconpicker/dist/icon-set/ionicons-v4.umd.js'
import '@quasar/quasar-ui-qiconpicker/dist/icon-set/material-icons-outlined.umd.js'
import '@quasar/quasar-ui-qiconpicker/dist/icon-set/material-icons-round.umd.js'
import '@quasar/quasar-ui-qiconpicker/dist/icon-set/material-icons-sharp.umd.js'
import '@quasar/quasar-ui-qiconpicker/dist/icon-set/material-icons.umd.js'
import '@quasar/quasar-ui-qiconpicker/dist/icon-set/mdi-v6.umd.js'
import '@quasar/quasar-ui-qiconpicker/dist/icon-set/themify.umd.js'
import '@quasar/quasar-ui-qiconpicker/dist/icon-set/lineawesome.umd.js'
import '@quasar/quasar-ui-qiconpicker/dist/icon-set/bootstrap-icons.umd.js'
export default {
  name: 'App'
}
</script>

<style>
</style>

Don’t add them all (unless you have this requirement). Remove the ones from above you won’t be needing.

1
2
3
4
5
import Vue from 'vue'
import Plugin from '@quasar/quasar-ui-qiconpicker'
import '@quasar/quasar-ui-qiconpicker/dist/index.css'

Vue.use(Plugin)

OR:

1
2
3
4
5
6
7
8
9
10
11
<style src="@quasar/quasar-ui-qiconpicker/dist/index.css"></style>

<script>
import { Component as QIconPicker } from '@quasar/quasar-ui-qiconpicker'

export default {
  components: {
    QIconPicker
  }
}
</script>

Exports window.QIconPicker.

Add the following tag(s) after the Quasar ones:

1
2
3
4
5
6
7
8
<head>
  <!-- AFTER the Quasar stylesheet tags: -->
  <link href="https://cdn.jsdelivr.net/npm/@quasar/quasar-ui-qiconpicker/dist/index.min.css" rel="stylesheet" type="text/css">
</head>
<body>
  <!-- at end of body, AFTER Quasar script(s): -->
  <script src="https://cdn.jsdelivr.net/npm/@quasar/quasar-ui-qiconpicker/dist/index.umd.min.js"></script>
</body>

If you need the RTL variant of the CSS, then go for the following (instead of the above stylesheet link):

<link href="https://cdn.jsdelivr.net/npm/@quasar/quasar-ui-qiconpicker/dist/index.rtl.min.css" rel="stylesheet" type="text/css">

For UMD variants only, there is also a caveat:

You must also load the QIconPicker icon set for the icon font(s) that you have loaded:

<script src="https://cdn.jsdelivr.net/npm/@quasar/quasar-ui-qiconpicker/dist/icon-set/material-icons.umd.js"></script>

Choices are:

  1. eva-icons.umd.js
  2. fontawesome-v5.umd.js
  3. ionicons-v4.umd.js
  4. material-icons-outlined.umd.js
  5. material-icons-round.umd.js
  6. material-icons-sharp.umd.js
  7. material-icons.umd.js
  8. mdi-v4.umd.js
  9. mdi-v5.umd.js
  10. mdi-v6.umd.js
  11. themify.umd.js
  12. line-awesome.umd.js
  13. bootstrap-icons.umd.js
You can only use one of `mdi-v4`, `mdi-v5` or `mdi-v6`

UMD Example on Codepen

Can be found here.

Can be found here.

Can be found here.

Can be found here.

QIconPicker will work with any of the defined Quasar Icon Sets. However, for this to work properly, you must make sure the icon set is included in your quasar.conf.js > extras.

WARNING

Most icon sets are very large which may cause performance issues.

TIP

In order to work properly, QIconPicker needs a specified height in it’s style (or parent style).

Added in v1.0.7, you can now get categories (tags) for the associated loaded icon set.

As of this writing, the Eva and Material Design icon sets are done. The Fontawesome v5 icon set is partially done. If you need an icon set that needs to be completed and is not, PRs are welcomed or DM me on the Discord channel.

You can get the tags with the tag event.

1
2
3
4
5
6
7
8
9
10
11
  <q-icon-picker
    v-model="name"
    :filter="filter"
    :icon-set="iconSet"
    :tags="tags"
    font-size="3em"
    tooltips
    :pagination.sync="pagination"
    @tags="onTags"
    style="height: calc(100vh - 140px)"
  />

Notice the @tags="onTags". Capturing this is a bit tricky. You need to set a guard to stop potential end-less loop in your Vue code (depending on how you use it). In your data () function set a guard variable; in this case loaded:

1
2
3
4
5
6
7
  data () {
    return {
      loaded: false,  // guard var
      tags: [],       // user selected tags to pass to QIconPicker
      categories: [], // keep track of categories
      selected: {}    // keep track of user selected categories
    }

in your methods section, add the event handler, and put the guard in to stop potential recursion:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  methods: {
    onTags (tags) {
      if (this.loaded !== true) {
        let cats = []
        let t = [ ...tags ]
        cats.splice(0, 0, ...t)
        this.categories.splice(0, this.categories.length, ...cats)
        this.categories.concat(...cats)
        this.categories.forEach(cat => {
          this.$set(this.selected, cat, false)
        })
        this.loaded = true
      }
    }
  }

This is all good and well, until you need to select a different icon-set. We can create the proper handlers in the watch section:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  watch: {
    iconSet (val) {
      this.loaded = false
      this.tags.splice(0, this.tags.length)
    },
    selected: {
      handler (val) {
        let tags = []
        this.categories.forEach(cat => {
          // if user has selected this tag...
          if (val[cat] === true) {
            // ...then keep track of it
            tags.push(cat)
          }
        })
        // push all user selected tags to QIconPicker
        this.tags.splice(0, this.tags.length, ...tags)
      },
      deep: true
    }
  },

Notice in the above code, the areas where the guard is reset with this.loaded = false.

You can see how this is handled on the Icons page. Remember, not all icon sets have been completed and PRs are very much welcomed.

QIconPicker API
Vue Component
Name
Type
String
Description

The name of a Quasar Icon Set

Values
material-icons, material-icons-outlined, material-icons-round, material-icons-sharp, ionicons-v4, mdi-v4, mdi-v5, mdi-v6, fontawesome-v5, eva-icons, themify, bootstrap-icons
Examples
icon-set="material-icons"
icon-set="fontawesome-v5"
Name
Type
Array
Description

An array of objects containing icon information. The object must contain the key name with the value being the icon name (ie: { name: 'bolt' }). Note: the icons used must already be loaded by Quasar.

Example
:icons="[{ name: 'calendar-today' }, { name: 'bolt' }]"
Definition
Name
Type
String
Description

The icon name

Name
Type
String
Default
''
Description

v-model; The selected icon

Examples
v-model="calendar_today"
v-model="bolt"

If you appreciate the work that went into this, please consider donating to Quasar or Jeff.


This page created with QMarkdown, another great Quasar App Extension.