Skip to content

Listbox

Move through a visible option list and select one or several values.

Usage

Single

Keep one active value while moving and selecting with keyboard or pointer input.

Keep one active value while moving and selecting with keyboard or pointer input.

ProductionCustomer-facing environment
StagingPre-release verification
DevelopmentLocal team workspace
Archived previewNo longer available

Multiple

Select several values independently without collapsing the existing selection.

Select several values independently without collapsing the existing selection.

ProductionCustomer-facing environment
StagingPre-release verification
DevelopmentLocal team workspace
Archived previewNo longer available

Follow focus

Move selection together with the active listbox item.

Move selection together with the active listbox item.

ProductionCustomer-facing environment
StagingPre-release verification
DevelopmentLocal team workspace
Archived previewNo longer available

Controlled

Let the parent own the current value and apply accepted changes back to the component.

Let the parent own the current value and apply accepted changes back to the component.

ProductionCustomer-facing environment
StagingPre-release verification
DevelopmentLocal team workspace
Archived previewNo longer available

API

Vue package: @sectile/vue/listbox

Components
  • ListboxRoot
  • ListboxItem
  • ListboxItemText
  • ListboxItemIndicator

Props

ListboxRootProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

defaultValue

Initial value used when the component owns its state.

disabled

Whether interaction is unavailable.

disabledItems

Item values excluded from focus and selection.

form

ID of the native form associated with the control.

items

Ordered item values managed by the component.

modelValue

Current value when state is controlled by the parent.

name

Name used for native form submission.

orientation

Axis used for layout and keyboard movement.

readonly

Whether the value can be inspected but not changed.

required

Whether the control must contain a valid value before submission.

selectionMode

Whether selection contains one value or multiple values.

textValue

Returns searchable or presentational text for an item value.

ListboxItemProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

disabled

Whether interaction is unavailable.

value

Current value exposed by this contract.

ListboxPartProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

Slots

ListboxRootSlotProps

disabled

Whether interaction is unavailable.

highlightedValue

Value currently highlighted for interaction.

readonly

Whether the value can be inspected but not changed.

value

Current value exposed by this contract.

ListboxItemSlotProps

disabled

Whether interaction is unavailable.

highlighted

Whether this item is highlighted for interaction.

selected

Whether this item is selected.

value

Current value exposed by this contract.

Events

ListboxRoot

activate

Emitted when an item becomes active.

highlight

Emitted when the highlighted item changes.

update:modelValue

Emitted when the component requests a new controlled value.

Other types

ListboxSelectionMode

ts
type ListboxSelectionMode = 'single' | 'multiple'

ListboxValue

ts
type ListboxValue = string | readonly string[]

ListboxTextValueResolver

ts
type ListboxTextValueResolver = NonNullable<ListboxRootProps['textValue']>

ListboxValueChangeHandler

ts
type ListboxValueChangeHandler = (value: ListboxValue) => void

ListboxHighlightHandler

ts
type ListboxHighlightHandler = (value: string | null) => void

ListboxActivateHandler

ts
type ListboxActivateHandler = (value: string) => void

Parts

Shared scope: [data-scope="listbox"]. Combine it with a part selector to keep styles local to this component.

PartSelectorRoleExtra attributes
root[data-part="root"]Defines the component boundary and owns its composed parts.
item[data-part="item"]Represents one selectable or actionable item.
item-text[data-part="item-text"]Renders the item label independently from its controls.
item-indicator[data-part="item-indicator"]Shows the item selection state.

Keyboard interaction

KeyBehavior
Arrow keysMove the active option in the visible orientation.
Home / EndMove to the first or last eligible option.
Enter / SpaceSelect or activate the current option.
Printable textMove to the next matching option when typeahead is available.

Accessibility

The labeled listbox exposes active, selected, and disabled option state without moving DOM focus to every item.

See the corresponding WAI-ARIA pattern for the host accessibility contract.

Released under the MIT License.