Data
Listbox
A list to choose one or several options from, always open: the sibling of Select.
WAI-ARIA tested
Import
main.ts
import { Listbox } from '@vitral/vue';Single
Selection follows the arrows, as in a native list box. Évora is disabled.
- São Paulo
- Rio de Janeiro
- Lisboa
- Porto
- Évora
- Montréal
- Bogotá
- Kraków
- Reykjavík
- Zürich
- Tōkyō
- Málaga
Multiple, with a filter
Search ignores accents and case: “ingles” is not needed, “espanol” finds Español.
- Português
- English
- Español
- Français
- Deutsch
- Íslenska
- Polski
- 日本語 (Japanese)
- Wolof
- Euskara
Groups and custom options
- Brasil
- São Paulo
- Recife
- Florianópolis
- Portugal
- Lisboa
- Coimbra
- Canada
- Montréal
- Québec
- Online
- Away
- Busy
- Offline
States
- São Paulo
- Rio de Janeiro
- Lisboa
- Porto
- São Paulo
- Rio de Janeiro
- Lisboa
- Porto
API
Read from packages/vue/src/components/Listbox/types.ts, so it says what the component actually accepts.
Props
| Name | Type | Description |
|---|---|---|
| options | any[] | — |
| optionLabel | string | Field (dotted path) holding an option's text. Without it, options are shown as they are. |
| optionValue | string | Field holding the value v-model receives. Without it, the whole option is the value. |
| optionDisabled | string | — |
| optionGroupLabel | string | Turns `options` into groups: this field is each group's label… |
| optionGroupChildren | string | …and this one its options. Defaults to `items`. |
| dataKey | string | Compare object values by this field instead of structurally. |
| multiple | boolean | v-model becomes an array, and the list is multi-selectable. |
| checkmark | boolean | Marks the selected options with a check, as well as with the highlight. |
| filter | boolean | Adds a search box above the list. |
| filterPlaceholder | string | — |
| filterFields | string[] | Fields to search instead of the label. |
| filterMatchMode | string | Any registered match mode; accent- and case-insensitive `contains` by default. |
| scrollHeight | string | The list's maximum height before it scrolls. |
| emptyMessage | string | — |
| emptyFilterMessage | string | — |
| selectOnFocus | boolean | In single mode, moving with the arrows also selects, the way a native list box does. Off, the arrows only move and Enter or Space selects. |
| invalid | boolean | — |
| disabled | boolean | — |
| fluid | boolean | — |
Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.
Emits
| Event | Payload | Description |
|---|---|---|
| change | event: ListboxChangeEvent | — |
| filter | query: string | — |
| focus | event: FocusEvent | — |
| blur | event: FocusEvent | — |
Slots
| Name | Slot props | Description |
|---|---|---|
| option | (props: { option: unknown; index: number; selected: boolean; focused: boolean }) | — |
| optiongroup | (props: { group: unknown }) | — |
| header | — | — |
| footer | — | — |
| empty | — | — |