Vue-multiselect: Using a custom dropdown icon

Created on 17 Aug 2017  路  12Comments  路  Source: shentao/vue-multiselect

No so much a bug, but I would like to use my own custom icon (drop-down arrow) but can't where to add in my HTML for it?

bug

Most helpful comment

@jackbarham Vue Multiselect 2.0.3 was released.
https://jsfiddle.net/yghbards/ Forked your fiddle with the updated version.

Sorry everyone for the delay. Trying to get back to active maintenance...

All 12 comments

It looks like this is now possible with the latest (github) version using the caret slot

          <template slot="caret">
            <div>
              <div @mousedown.prevent.stop="toggle()" class="multiselect__select">
                <icon name="plus" style="color:green;"></icon>
              </div>

            </div>
          </template>

Whatever you put in the slot template will be set as the caret, in my case a vue-awesome icon.
In this case I have a local toggle method which calls the multiselect toggle method using a ref
You will also have to override some css or include your own.

Another option is using only css by for instance adding a background url to an image and removing the current caret by overriding some styles.

Thanks for the suggestion, but I can't get it to work. I'm using version 2.0.2 and this is my code:

<multiselect v-model="country" :options="countries" placeholder="Select or type to search" <multiselect v-model="country" :options="countries" placeholder="Select or type to search" label="label">
    <template slot="caret">
        <div>
            <div @mousedown.prevent.stop="toggle()" class="multiselect__select">
                <i class="icon-down"></i>
            </div>
        </div>
    </template>
</multiselect>

But nothing is displaying back in the HTML

It will not work on the latest npm version. I had to clone this git and run the build script (not sure if the build was necessary) Grep the dist js file for "caret" to see if you have it.

Thanks, I'll wait until they release a stable version. Thanks for the heads-up though. Looks like it's on the way.

Weird. Could you please provide a reproduction on jsfiddle?

I have added this Fiddle: https://jsfiddle.net/jackbarham/5zh4ob3a

For now, I've used <span>test</span> in the slot to see if something else appears, but it doesn't.

Did you have a chance to look at the fiddle @shentao?

@jackbarham, I think slot name is "carret", not caret

Eh, just noticed that the change wasn鈥檛 released yet (and there was a change in the name). Will push a fix today. Sorry :/

Thanks, @shentao - I'll check this evening.

@jackbarham Vue Multiselect 2.0.3 was released.
https://jsfiddle.net/yghbards/ Forked your fiddle with the updated version.

Sorry everyone for the delay. Trying to get back to active maintenance...

Thank you. Works perfectly.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

icebob picture icebob  路  4Comments

alexhyriavets picture alexhyriavets  路  3Comments

hskrishna29 picture hskrishna29  路  3Comments

yaakovp picture yaakovp  路  3Comments

focussing picture focussing  路  3Comments