Skip to content
On this page

select

select component with option search

template

html
<script>
export default {
	data () {
		return {
			selection: '',
			complexOptions: [
				{id: 1, name: 'One', color: 'red'},
				{id: 2, name: 'Two', color: 'blue'},
				{id: 3, name: 'Three', color: 'green'},
				{id: 5, name: 'Five', color: 'orange'},
			],
			activeComplexOption: 2,
		}
	}
}
</script>

<bunt-select name="a-select" label="Select something" v-model="selection" :options="['Delicious Pizza', 'All The Kebab', 'Burrrrrrito!', 'Noodles, Peking Duck', 'McKingC', 'Linsa mit Spätzle und Saita', 'Ice, Ice, Baby', 'Egg and bacon', 'Egg, sausage and bacon', 'Egg and Spam', 'Egg, bacon and Spam', 'Egg, bacon, sausage and Spam', 'Spam, bacon, sausage and Spam', 'Spam, egg, Spam, Spam, bacon and Spam', 'Spam, Spam, Spam, egg and Spam', 'Spam, Spam, Spam, Spam, Spam, Spam, baked beans, Spam, Spam, Spam and Spam', 'Lobster Thermidor aux crevettes with a Mornay sauce, garnished with truffle pâté, brandy and a fried egg on top, and Spam.']" />
<p>{{ selection }}</p>
<bunt-select id="select-complex" name="complex-select" label="complex select" icon="palette" v-model="activeComplexOption" :options="complexOptions" option-label="name">
	<template slot-scope="{ option }">
		<div class="name">{{ option.name }}</div>
		<div class="id" :style="{'background-color': option.color}">{{ option.id }}</div>
	</template>
</bunt-select>

<!-- add a div for all dropdowns to teleport to somewhere at the end of your html, preferably directly in <body> -->
<div id="bunt-teleport-target"></div>

style

stylus
#select-none, #select-complex
	select-style()
#select-complex
	ul li
		display: flex
		justify-content: space-between
		.id
			width: 120px
			text-align: right
			padding: 0 8px
			color: $clr-secondary-text-dark

props

proptyperequireddefaultdescription
namestringtruenative input name
labelstringfalsefloating label
placeholderstringfalsenative placeholder text
hintstringfalsehint text
hintIsHtmlbooleanfalsefalsepass hint through v-html (potentially unsave)
iconstringfalsemdi icon name to display
valuestring|number|objectfalsenellvalue (or use v-model)
optionsarrayfalse[]array of strings or objects of all choices
option-labelstringfalse'label'label attribute of option object
get-option-labelfunctionfalseusing option-labelfunction to generate label from option objects
option-valuestringfalse'id'value attribute of option object
get-option-valuefunctionfalseusing option-valuefunction to get value from option object
disabledbooleanfalsefalsedisables input
validationobjectfalsevuelidate object (see validation)

slots

slotscopedescription
defaultrender a single option in the dropdown
result-headeroptional area before the options list inside dropdown
no-optionsrenders when search does not match

events

eventargsdescription
inputvalueemitted on every keypress or input (or use v-model)
blurafter dropdown closes

functions

TODO

style mixin parameters

parametertypedefaultdescription
style'light', 'dark''link'button style
size'dense', 'large', 'compact''dense'input size (compact does not reserve space for a hint)

Released under the MIT License.