Select
A dropdown menu similar to the HTML <select>
element.
Menu items are provided as an array of MenuItemData types, and v-model
is used to bind the current selection's value.
Demos
Configurable
Name | Value |
---|---|
Props | |
disabled | |
defaultLabel | |
defaultIcon | |
Note: For icon properties, the relevant icon also needs to be imported from the @wikimedia/codex-icons package. See the usage documentation for more information. |
Basic Usage
Menu items must have a value, and can have a label to display in the UI. If no label is provided (like the third menu item in this example), the value will be displayed.
With menu item icons and descriptions
Items are displayed via the MenuItem component—see the MenuItem docs for more options. In this example, a menuConfig
object is passed to the Select to bold the label text and hide the text overflow of the descriptions.
With custom menu item display
The menu-item
scoped slot enables you to customize the display of each menu item, with a binding for the menuItem
. In this example, only the menu item's icon is displayed in the menu.
With custom label display
The label
scoped slot enables you to customize the display of the label, with bindings for the selectedMenuItem
and the defaultLabel
.
Usage
Props
Prop name | Description | Type | Default |
---|---|---|---|
menuItems (required) | Menu items. See the MenuItemData type. | MenuItemData[] | |
selected (required) | Value of the current selection. Must be bound with v-model:selected .The property should be initialized to null rather than using a falsy value. | string|number|null | |
defaultLabel | Label to display when no selection has been made. | string | '' |
disabled | Whether the dropdown is disabled. | boolean | false |
menuConfig | Configuration for various menu features. All properties default to false. See the MenuConfig type. | MenuConfig | () => { return {} as MenuConfig; } |
defaultIcon | An icon at the start of the select element displayed when no selection has been made. | Icon | undefined | undefined |
Events
Event name | Properties | Description |
---|---|---|
update:selected | modelValue string | number | null - The new model value | When the selection value changes. |
Slots
Name | Description | Bindings |
---|---|---|
label | Display of the current selection or default label | |
menu-item | Display of an individual item in the menu |