Skip to content

Combobox

Filter a collection with text, move through matches, and accept one result.

Usage

Prefix

Filter items whose labels begin with the current query.

Filter items whose labels begin with the current query.

Add an environment

Contains

Filter items whose labels contain the query instead of only matching its prefix.

Filter items whose labels contain the query instead of only matching its prefix.

Add an environment

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.

Add an environment

Examples

IME

Keep composition text separate until an IME commit produces the accepted query.

Keep composition text separate until an IME commit produces the accepted query.

Add an environment

Floating positioning

This component uses the shared positioning engine. Use the live positioning example to change side, align, offsets, collision boundaries, strategy, and tracking while inspecting the resolved placement.

API

Vue package: @sectile/vue/combobox

Components
  • ComboboxRoot
  • ComboboxInput
  • ComboboxContent
  • ComboboxItem
  • ComboboxEmpty

Props

ComboboxRootProps

align

Alignment of positioned content relative to its anchor.

as

Element or component rendered for this part.

asChild

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

avoidCollisions

Whether positioned content may flip or shift to remain visible.

collisionBoundary

Boundary used to keep positioned content visible.

collisionPadding

Space kept between positioned content and its collision boundary.

defaultInputValue

Initial uncontrolled text shown by the editable input.

defaultOpen

Initial uncontrolled open state.

defaultValue

Initial value used when the component owns its state.

disabled

Whether interaction is unavailable.

hideWhenDetached

Whether positioned content hides when its anchor leaves the layout.

inputValue

Controlled text currently shown by the editable input.

items

Ordered item values managed by the component.

label

Accessible name announced for the control.

modelValue

Current value when state is controlled by the parent.

open

Whether the associated popup or disclosure is open.

policies

Behavior policies that customize validation, movement, or selection.

position

Whether the popup is positioned relative to its trigger.

readonly

Whether the value can be inspected but not changed.

side

Preferred side of the anchor for positioned content.

sideOffset

Distance between positioned content and its anchor.

strategy

CSS positioning strategy used for anchored content.

tracking

Update strategy used while anchored content is open.

ComboboxItemProps

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.

ComboboxPartProps

as

Element or component rendered for this part.

asChild

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

Slots

ComboboxRootSlotProps

disabled

Whether interaction is unavailable.

highlightedValue

Value currently highlighted for interaction.

inputValue

Current editable input text.

open

Whether the associated popup or disclosure is open.

readonly

Whether the value can be inspected but not changed.

value

Current value exposed by this contract.

ComboboxItemSlotProps

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

ComboboxRoot

accept

Emitted when the current draft becomes an accepted value.

highlight

Emitted when the highlighted item changes.

update:inputValue

Emitted when editable input text changes.

update:modelValue

Emitted when the component requests a new controlled value.

update:open

Emitted when the component requests a new open state.

Other types

ComboboxValueChangeHandler

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

ComboboxInputValueChangeHandler

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

ComboboxOpenChangeHandler

ts
type ComboboxOpenChangeHandler = (value: boolean) => void

ComboboxHighlightHandler

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

ComboboxAcceptHandler

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

Parts

Shared scope: [data-scope="combobox"]. 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.
input[data-part="input"]Accepts the editable value or draft.
content[data-part="content"]Contains the component content shown for the active state.
item[data-part="item"]Represents one selectable or actionable item.
empty[data-part="empty"]Shows feedback when no collection item matches.

Keyboard interaction

KeyBehavior
Arrow Down / Arrow UpOpen the popup and move the active option.
EnterAccept the active option.
EscapeClose the popup without replacing the accepted value.
Text inputFilter options without breaking IME composition.

Accessibility

The input exposes autocomplete, expanded state, popup ownership, and the active descendant while options expose selection.

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

Released under the MIT License.