Select
Demos
Size variants
Available size variants for the ui prop: xs / s / m / l.
<template>
<article>
<veui-select
v-model="license"
ui="l"
:options="options"
/>
<veui-select
v-model="license"
:options="options"
/>
<veui-select
v-model="license"
ui="s"
:options="options"
/>
<veui-select
v-model="license"
ui="xs"
:options="options"
/>
</article>
</template>
<script>
import { Select } from 'veui'
export default {
components: {
'veui-select': Select
},
data () {
return {
license: null,
options: [
{
label: 'MIT',
value: 'mit'
},
{
label: 'BSD',
value: 'bsd'
},
{
label: 'Apache 2.0',
value: 'apache2'
}
]
}
}
}
</script>
<style lang="less" scoped>
.veui-select {
max-width: 120px;
margin-right: 10px;
}
</style>
Using embedded OptionGroups & Options
Can be used with embedded OptionGroups & Options.
Selected: -
clearable can be used to allow selected values to be discarded for Select. Set position of the embedded OptionGroups to popup to display children options inside a popup menu.
<template>
<article>
<veui-select
v-model="item"
placeholder="Pick one..."
clearable
>
<veui-option-group
label="Editors"
position="popup"
>
<veui-option
value="vscode"
label="VSCode"
/>
<veui-option
value="sublime"
label="SublimeText"
/>
<veui-option
value="atom"
label="Atom"
/>
</veui-option-group>
<veui-option-group
label="Browsers"
position="popup"
>
<veui-option-group
label="Desktop"
position="popup"
>
<veui-option
value="ie"
label="IE"
/>
<veui-option
value="edge"
label="Edge"
/>
<veui-option
value="firefox"
label="Firefox"
/>
<veui-option
value="chrome"
label="Chrome"
/>
</veui-option-group>
<veui-option-group
label="Mobile"
position="popup"
>
<veui-option
value="ios_safari"
label="iOS Safari"
/>
<veui-option
value="android"
label="Android Browser"
/>
<veui-option
value="android_chrome"
label="Chrome for Android"
/>
</veui-option-group>
</veui-option-group>
</veui-select>
<p>Selected: {{ item || '-' }}</p>
</article>
</template>
<script>
import { Select, OptionGroup, Option } from 'veui'
export default {
components: {
'veui-select': Select,
'veui-option-group': OptionGroup,
'veui-option': Option
},
data () {
return {
item: null
}
}
}
</script>
<style lang="less" scoped>
.veui-select {
width: 180px;
}
</style>
Searchable options
Use the searchable prop to make options searchable.
<template>
<article>
<veui-select
v-model="license"
:options="options"
searchable
/>
</article>
</template>
<script>
import { Select } from 'veui'
export default {
components: {
'veui-select': Select
},
data () {
return {
license: null,
options: [
{
label: 'MIT',
value: 'mit'
},
{
label: 'BSD',
value: 'bsd'
},
{
label: 'Apache 2.0',
value: 'apache2'
}
]
}
}
}
</script>
Multiple selections
Use the multiple prop to enable multiple selections.
Use max to specify the max number of options that can be selected. The searchable prop can also be used here to make options searchable.
<template>
<article>
<section>
<veui-checkbox v-model="searchable">
Searchable
</veui-checkbox>
</section>
<section>
<veui-select
v-model="license"
multiple
:options="options"
:max="5"
:searchable="searchable"
/>
</section>
</article>
</template>
<script>
import { Select, Checkbox } from 'veui'
export default {
components: {
'veui-select': Select,
'veui-checkbox': Checkbox
},
data () {
return {
searchable: false,
license: null,
options: [
{
label: 'MIT',
value: 'mit'
},
{
label: 'BSD',
value: 'bsd'
},
{
label: 'Apache 2.0',
value: 'apache2'
},
{
label: 'GPL 3.0',
value: 'gpl3'
},
{
label: 'AGPL 3.0',
value: 'agpl3'
},
{
label: 'LGPL 2.1',
value: 'lgpl2'
},
{
label: 'MPL 2.0',
value: 'mpl2'
}
]
}
}
}
</script>
<style lang="less" scoped>
section {
margin-bottom: 1em;
}
</style>
API
Props
| Name | Type | Default | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ui | string= | - | Style variants.
| |||||||||||||||
options | Array<Object> | - | The list of options with the option type being
| |||||||||||||||
value | Array<*>|* | - |
The value of the selected option. | |||||||||||||||
multiple | boolean | false | Whether users can select multiple items. | |||||||||||||||
max | number | - | The max items users can select. | |||||||||||||||
placeholder | string | select.placeholder | Placeholder text when no option is selected. | |||||||||||||||
clearable | boolean | false | Whether the select is clearable. | |||||||||||||||
searchable | boolean | false | Whether the options are searchable. | |||||||||||||||
filter | function | - | Filter function for the options. The type is function(option: Object): boolean. The type of option is the same as the options prop. The return value denotes whether the option is shown inside the options dropdown. | |||||||||||||||
expanded | boolean= | false |
Whether the dropdown menu is expanded. | |||||||||||||||
disabled | boolean= | false | Whether the select is disabled. | |||||||||||||||
readonly | boolean= | false | Whether the select is read-only. | |||||||||||||||
overlay-class | string | Array | Object= | - | See the overlay-class prop of the Overlay component. | |||||||||||||||
overlay-style | string | Array | Object= | - | See the overlay-style prop of the Overlay component. |
Slots
| Name | Description | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
default | The content of the options dropdown layer. Can be used to place Options or OptionGroupss when the options prop is not specified. | |||||||||||||||||||||
before | The content before the options in the dropdown layer. No default content.
| |||||||||||||||||||||
after | The content after the options in the dropdown layer. No default content. | |||||||||||||||||||||
label | The content of the select button. Displays the
Additionally, custom properties apart from the listed ones will also be passes into the scope object via | |||||||||||||||||||||
group-label | The label text of each option group (option with child
Additionally, custom properties in current option, apart from the listed ones, will also be passes into the scope object via | |||||||||||||||||||||
option-label | The label text of each option (option without child
Additionally, custom properties in current option, apart from the listed ones, will also be passes into the scope object via | |||||||||||||||||||||
option | The entire content area of each option (option without child
Additionally, custom properties in current option, apart from the listed ones, will also be passes into the scope object via | |||||||||||||||||||||
trigger | The entire drop-down trigger area. Displays the select input by default.
|
Events
| Name | Description |
|---|---|
change |
Triggers when the selected option changed. The callback parameter list is |
toggle | Triggered when the expanded state is going to change. The callback parameter list is (expanded: boolean). expanded denotes whether the dropdown menu is to be expanded or collapsed. |
Configs
| Key | Type | Default | Description |
|---|---|---|---|
select.placeholder | string | @@select.placeholder | The placeholder text when no option is selected. |
Icons
| Name | Description |
|---|---|
expand | Expand the dropdown layer. |
collapse | Collapse the dropdown layer. |