Combobox
An input combined with a list of predefined items to select.
Usage guidelines
- Combobox is a filterable Select: Use Combobox when the input is restricted to a set of predefined selectable items, similar to Select but whose items are filterable using an input. Prefer using Combobox over Select when the number of items is sufficiently large to warrant filtering.
- Avoid for simple search widgets: Combobox does not allow free-form text input. For search widgets, consider using Autocomplete instead.
- Avoid when not rendering an input: Use Select instead of Combobox if no input is being rendered, which includes accessibility features specific to a listbox without an input.
- Form controls must have an accessible name: If
<Combobox.Input>is the form control, label it with a native<label>or<Field.Label>, or provide anaria-labelwhen no visible label is rendered.<Combobox.Label>labels<Combobox.Trigger>and is intended for the input-inside-popup pattern, where the trigger is the form control. See the forms guide. - Closing animations: The popup stays rendered until its closing animation finishes. See Manual unmounting for animating it with a JavaScript library and for manual control.
Anatomy
Import the components and place them together:
Item values
Each <Combobox.Item> takes a value prop identifying it. Pass the item being rendered. <Combobox.List> takes static children in Svelte, so render the items with <Combobox.Collection>, whose children snippet receives each item:
That item is what value, defaultValue, and onValueChange receive. To store IDs instead, see Value selection with IDs.
Examples
Typed wrapper component
The following example shows a typed wrapper around the Combobox component with correct type inference and type safety. Each bindable prop of <Combobox.Root> is forwarded with bind::
The third Item type parameter is what lets the wrapper accept a Combobox.createItems() collection, whose rendered item type differs from its selection value. Omit it and a collection infers Value as the source item type, surfacing an error on defaultValue rather than on items.
Value selection with IDs
When your app stores IDs rather than item objects, use Combobox.createItems with getValue and getLabel to derive each item's selection value and display label.
With static data, create the collection at module scope. The accessor parameters are inferred from users. Pass the derived ID to the value prop of <Combobox.Item>, not the item being rendered:
Selection props and events use the derived IDs, while list rendering continues to receive the original items. The derived label is also used for filtering and typeahead.
When the data is loaded or replaced at runtime, derive the collection from it so that it is rebuilt only when the data changes:
As a rule of thumb, use primitive items for simple lists, object values when the selected record is useful application state, and createItems() when selection should use a stable primitive ID while rendering and filtering still use object records.
Stable IDs preserve item matching when an async data library replaces row objects during a refetch. With object values, use isItemEqualToValue to compare their IDs instead.
When results are filtered externally (for example, by a server-side search), items represents records known to the app, while filteredItems represents the current result window displayed in the popup. Pass source items rather than derived values to filteredItems, preserving the flat or grouped structure of items:
Include the selected user's record in knownUsers so its label remains available when it is outside searchResults. Alternatively, provide itemToStringLabel when the label can be derived from the selected value alone.
Multiple select
The combobox can allow multiple selections by adding the multiple prop to <Combobox.Root>.
Selection chips are rendered with <Combobox.Chip> inside the input that can be removed.
In order for screen readers to announce how to reach and remove the chips, add aria-description to <Combobox.Chip> and <Combobox.Input>, alongside the aria-label on <Combobox.Chips> and <Combobox.ChipRemove>.
Base UI does not ship these strings. Translate them together with the rest of your interface.
Visible chips can be limited by slicing the selected values rendered in <Combobox.Value>:
Keeping the filter after selection
In multiple mode, selecting an item clears the typed filter and closes the popup when the input is rendered outside it. To let users pick several results from one query, cancel the relevant change request.
Which request to cancel depends on the input's placement. When the input is outside the popup, cancel the item-press close request in onOpenChange. When it is inside, cancel the clear request in onInputValueChange, marked with eventDetails.isItemPress.
The typed filter still resets once the popup closes.
Input inside popup
<Combobox.Input> can be rendered inside <Combobox.Popup> to create a searchable select popup.
Use <Combobox.Label> to provide a visible label for the combobox trigger in this pattern:
<Combobox.Label> renders a <div>, so clicking it focuses the combobox trigger without opening the popup.
Grouped
Organize related options with <Combobox.Group> and <Combobox.GroupLabel> to add section headings inside the popup.
Groups are represented by an array of objects with an items property, which itself is an array of individual items for each group. An extra property, such as value, can be provided for the heading text when rendering the group label.
Async search (single)
Load items from a remote source by fetching on input changes. Keep the selected item in the items list so it remains available while new results stream in. This pattern avoids needing to load items upfront.
Async search (multiple)
Load items from a remote source by fetching on input changes while supporting multiple selections. Selected items remain available in the list while new matches stream in. This pattern avoids needing to load items upfront.
Creatable
Create a new item when the filter matches no items, opening a creation <Dialog>.
Virtualized
Efficiently handle large datasets using a virtualization library like @tanstack/svelte-virtual. The demo below renders the visible window itself, so it needs no dependency.
Memoizing items
Svelte updates only what changed, so items need no memoizing: <Combobox.Collection> keys each item by its value and reuses the components of unchanged items while the filter changes. This is enough for datasets up to roughly 1,000 items. While it speeds up typing, it does not speed up opening; with a large enough number of items, the mount cost dominates, and virtualization becomes necessary to keep the open interaction fast on low-end devices.
API reference
Root
Groups all parts of the combobox. Renders no element of its own, only the hidden inputs a form submits and validates.
value ComboboxValueOf<Value, Multiple> —
- Name
- Description
The selected value. Use
bind:valueto share it with the parent. Without a binding it starts fromdefaultValue.- Type
ComboboxValueOf<Value, Multiple>- Binding
bind:value
defaultValue ComboboxValueOf<Value, Multiple> null, or [] when `multiple`
- Name
- Description
The value the combobox starts with and the value a form reset restores.
- Type
ComboboxValueOf<Value, Multiple>- Default
null, or [] when `multiple`
onValueChange function —
- Name
- Description
Called before the value changes. Call
eventDetails.cancel()to keep the current value.- Type
(value: ComboboxValueOf<Value, Multiple>, eventDetails: ComboboxChangeEventDetails) => void
multiple Multiple false
- Name
- Description
Whether several items can be selected.
- Type
Multiple- Default
false
autocomplete FullAutoFill | null —
- Name
- Description
A hint for browser autofill, on the hidden input.
- Type
FullAutoFill | null
autoHighlight boolean false
- Name
- Description
Whether the first matching item is highlighted while filtering.
- Type
boolean- Default
false
inputValue string —
- Name
- Description
The text in the input. Use
bind:inputValueto share it with the parent. Without a binding it starts fromdefaultInputValue.- Type
string- Binding
bind:inputValue
defaultInputValue string —
- Name
- Description
The text the input starts with.
- Type
string
onInputValueChange function —
- Name
- Description
Called before the input value changes. Call
eventDetails.cancel()to keep the text.- Type
(inputValue: string, eventDetails: ComboboxChangeEventDetails) => void
open boolean false
- Name
- Description
Whether the popup is open. Use
bind:opento share it with the parent.- Type
boolean- Default
false- Binding
bind:open
onOpenChange function —
- Name
- Description
Called before the popup opens or closes. Call
eventDetails.cancel()to veto it.- Type
(open: boolean, eventDetails: ComboboxOpenChangeEventDetails) => void
onOpenChangeComplete function —
- Name
- Description
Called after the open or close animations finish.
- Type
(open: boolean) => void
onItemHighlighted function —
- Name
- Description
Called when an item is highlighted or the highlight is cleared (
undefined).- Type
(itemValue: Value | undefined, eventDetails: ComboboxHighlightEventDetails) => void
name string —
- Name
- Description
Identifies the field when a form is submitted.
- Type
string
form string —
- Name
- Description
Id of the form the hidden inputs belong to, for a combobox rendered outside it.
- Type
string
id string —
- Name
- Description
The id of the component.
- Type
string
required boolean false
- Name
- Description
Whether a value must be chosen before the form submits.
- Type
boolean- Default
false
readonly boolean false
- Name
- Description
Whether the user can browse the items but not choose a different one.
- Type
boolean- Default
false
disabled boolean false
- Name
- Description
Whether the component ignores user interaction.
- Type
boolean- Default
false
openOnInputClick boolean true
- Name
- Description
Whether the popup opens when the input is pressed.
- Type
boolean- Default
true
keepHighlight boolean false
- Name
- Description
Whether the highlighted item stays highlighted when the pointer leaves the list.
- Type
boolean- Default
false
highlightItemOnHover boolean true
- Name
- Description
Whether moving the pointer over items highlights them. Set
falseto tell CSS:hoverapart from thedata-highlightedstate.- Type
boolean- Default
true
loopFocus boolean true
- Name
- Description
Whether the arrow keys loop from the last item back to the input and then the first item.
- Type
boolean- Default
true
grid boolean false
- Name
- Description
Whether items are laid out in a grid of
Combobox.Rows. The arrow keys move across rows and columns.- Type
boolean- Default
false
items ComboboxItems<Item, Value> —
- Name
- Description
The items of the list: flat, grouped, or a
createItems()collection.- Type
ComboboxItems<Item, Value>
filteredItems ComboboxItemsData<Item> —
- Name
- Description
Items filtered by the consumer. The list shows them instead of filtering
itemsitself. With acreateItems()collection, pass source items.- Type
ComboboxItemsData<Item>
filter function | null —
- Name
- Description
Matches an item against the query.
nulldisables filtering. Receives the source item of acreateItems()collection.- Type
((item: Item, query: string, itemToString?: (item: Item) => string) => boolean) | null
itemToStringLabel function —
- Name
- Description
Converts an object value to the label shown in the input and matched against the query. A
{ value, label }object uses itslabelwithout it.- Type
(itemValue: Value) => string
itemToStringValue function —
- Name
- Description
Converts an object value to the string a form submits. A
{ value, label }object uses itsvaluewithout it.- Type
(itemValue: Value) => string
isItemEqualToValue function Object.is
- Name
- Description
Whether an item value matches the selected value. Use it for object values that are not the same reference.
- Type
(itemValue: Value, value: Value) => boolean- Default
Object.is
inline boolean false
- Name
- Description
Whether the list renders inline instead of in a popup. Set
openwith it.- Type
boolean- Default
false
virtualized boolean false
- Name
- Description
Whether an external virtualizer renders a window of the items. Give each rendered item its
index, or avaluefromitemsto look its index up. Typing leaves the list scroll to the virtualizer.- Type
boolean- Default
false
modal boolean false
- Name
- Description
Whether the popup is modal while open: page scroll is locked and outside pointer interaction is blocked.
- Type
boolean- Default
false
limit number -1
- Name
- Description
The maximum number of items the list shows.
-1shows all.- Type
number- Default
-1
locale Intl.LocalesArgument —
- Name
- Description
The locale used to compare strings. Defaults to the runtime locale.
- Type
Intl.LocalesArgument
submitOnItemClick boolean false
- Name
- Description
Whether pressing an item submits the owning form.
- Type
boolean- Default
false
Label
An accessible label for the trigger. Renders a <div> element. When the input is the form control, label it with a native <label> or Field.Label.
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxLabelState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxLabelState, children: Snippet | undefined]>
disabled boolean
- Name
disabled- Description
Whether the component should ignore user interaction.
- Type
boolean
touched boolean
- Name
touched- Description
Whether the field has been touched.
- Type
boolean
dirty boolean
- Name
dirty- Description
Whether the field value has changed from its initial value.
- Type
boolean
valid boolean | null
- Name
valid- Description
Whether the field is valid.
nullmeans validity is not known yet.- Type
boolean | null
filled boolean
- Name
filled- Description
Whether the field has a value.
- Type
boolean
focused boolean
- Name
focused- Description
Whether the field is focused.
- Type
boolean
Value
The label of the selected value, or of each selected value. Renders no element.
placeholder string —
- Name
- Description
Shown while nothing is selected.
childrenreplaces it.- Type
string
children Snippet<[value: unknown]> —
- Name
- Description
Formats the selected value. Treat the value as read-only.
- Type
Snippet<[value: unknown]>
Icon
An icon that shows the control opens a popup. Renders a <span> element.
render Snippet<[props: HTMLAttributes<HTMLSpanElement>, state: ComboboxIconState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLAttributes<HTMLSpanElement>, state: ComboboxIconState, children: Snippet | undefined]>
Input
A text input to search for items in the list. Renders an <input> element.
disabled boolean | null false
- Name
- Description
Whether the input ignores user interaction.
- Type
boolean | null- Default
false
render Snippet<[props: HTMLInputAttributes, state: ComboboxInputState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLInputAttributes, state: ComboboxInputState, children: Snippet | undefined]>
open boolean
- Name
open- Description
Whether the popup is open.
- Type
boolean
disabled boolean
- Name
disabled- Description
Whether the control ignores user interaction.
- Type
boolean
readOnly boolean
- Name
readOnly- Description
Whether the combobox is read-only.
- Type
boolean
popupSide Side | null
- Name
popupSide- Description
The side the popup is placed on, while it is mounted.
- Type
Side | null
listEmpty boolean
- Name
listEmpty- Description
Whether the filtered list has no items.
- Type
boolean
touched boolean
- Name
touched- Description
Whether the field has been touched.
- Type
boolean
dirty boolean
- Name
dirty- Description
Whether the field value has changed from its initial value.
- Type
boolean
valid boolean | null
- Name
valid- Description
Whether the field is valid.
nullmeans validity is not known yet.- Type
boolean | null
filled boolean
- Name
filled- Description
Whether the field has a value.
- Type
boolean
focused boolean
- Name
focused- Description
Whether the field is focused.
- Type
boolean
data-popup-open
data-pressed
data-disabled
data-readonly
data-required
data-popup-side
data-list-empty
data-valid
Field.Root ancestor.data-invalid
Field.Root ancestor.data-dirty
Field.Root ancestor.data-touched
Field.Root ancestor.data-filled
Field.Root ancestor.data-focused
Field.Root ancestor.InputGroup
Groups the input with its related controls. Renders a <div> element.
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxInputGroupState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxInputGroupState, children: Snippet | undefined]>
placeholder boolean
- Name
placeholder- Description
Whether nothing is selected.
- Type
boolean
open boolean
- Name
open- Description
Whether the popup is open.
- Type
boolean
disabled boolean
- Name
disabled- Description
Whether the control ignores user interaction.
- Type
boolean
readOnly boolean
- Name
readOnly- Description
Whether the combobox is read-only.
- Type
boolean
popupSide Side | null
- Name
popupSide- Description
The side the popup is placed on, while it is mounted.
- Type
Side | null
listEmpty boolean
- Name
listEmpty- Description
Whether the filtered list has no items.
- Type
boolean
touched boolean
- Name
touched- Description
Whether the field has been touched.
- Type
boolean
dirty boolean
- Name
dirty- Description
Whether the field value has changed from its initial value.
- Type
boolean
valid boolean | null
- Name
valid- Description
Whether the field is valid.
nullmeans validity is not known yet.- Type
boolean | null
filled boolean
- Name
filled- Description
Whether the field has a value.
- Type
boolean
focused boolean
- Name
focused- Description
Whether the field is focused.
- Type
boolean
data-popup-open
data-pressed
data-disabled
data-readonly
data-popup-side
data-list-empty
data-placeholder
data-valid
Field.Root ancestor.data-invalid
Field.Root ancestor.data-dirty
Field.Root ancestor.data-touched
Field.Root ancestor.data-filled
Field.Root ancestor.data-focused
Field.Root ancestor.Clear
Clears the value when clicked. Renders a <button> element.
disabled boolean | null false
- Name
- Description
Whether the button ignores user interaction.
- Type
boolean | null- Default
false
nativeButton boolean true
- Name
- Description
Whether the host is a native
<button>.- Type
boolean- Default
true
keepMounted boolean false
- Name
- Description
Whether the button stays in the DOM while there is nothing to clear.
- Type
boolean- Default
false
render Snippet<[props: HTMLButtonAttributes, state: ComboboxClearState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLButtonAttributes, state: ComboboxClearState, children: Snippet | undefined]>
open boolean
- Name
open- Description
Whether the popup is open.
- Type
boolean
disabled boolean
- Name
disabled- Description
Whether the button ignores user interaction.
- Type
boolean
visible boolean
- Name
visible- Description
Whether there is something to clear.
- Type
boolean
transitionStatus 'starting' | 'ending' | 'idle' | undefined
- Name
transitionStatus- Type
'starting' | 'ending' | 'idle' | undefined
data-popup-open
data-disabled
data-visible
data-starting-style
data-ending-style
Trigger
A button that opens the popup. Renders a <button> element.
disabled boolean | null —
- Name
- Description
Whether the trigger ignores user interaction.
- Type
boolean | null
nativeButton boolean true
- Name
- Description
Whether the host is a native
<button>. Setfalsewhenrendersupplies a non-button element.- Type
boolean- Default
true
id string | null —
- Name
- Description
The trigger's id. With the input inside the popup, defaults to the root's id.
- Type
string | null
render Snippet<[props: HTMLButtonAttributes, state: ComboboxTriggerState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLButtonAttributes, state: ComboboxTriggerState, children: Snippet | undefined]>
placeholder boolean
- Name
placeholder- Description
Whether nothing is selected.
- Type
boolean
open boolean
- Name
open- Description
Whether the popup is open.
- Type
boolean
disabled boolean
- Name
disabled- Description
Whether the control ignores user interaction.
- Type
boolean
readOnly boolean
- Name
readOnly- Description
Whether the combobox is read-only.
- Type
boolean
popupSide Side | null
- Name
popupSide- Description
The side the popup is placed on, while it is mounted.
- Type
Side | null
listEmpty boolean
- Name
listEmpty- Description
Whether the filtered list has no items.
- Type
boolean
touched boolean
- Name
touched- Description
Whether the field has been touched.
- Type
boolean
dirty boolean
- Name
dirty- Description
Whether the field value has changed from its initial value.
- Type
boolean
valid boolean | null
- Name
valid- Description
Whether the field is valid.
nullmeans validity is not known yet.- Type
boolean | null
filled boolean
- Name
filled- Description
Whether the field has a value.
- Type
boolean
focused boolean
- Name
focused- Description
Whether the field is focused.
- Type
boolean
data-popup-open
data-pressed
data-disabled
data-readonly
data-required
data-popup-side
data-list-empty
data-placeholder
data-valid
Field.Root ancestor.data-invalid
Field.Root ancestor.data-dirty
Field.Root ancestor.data-touched
Field.Root ancestor.data-filled
Field.Root ancestor.data-focused
Field.Root ancestor.Chips
A container for the chips in a multiselectable input. Renders a <div> element.
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxChipsState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxChipsState, children: Snippet | undefined]>
Chip
An individual chip that represents a value in a multiselectable input. Renders a <div> element.
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxChipState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxChipState, children: Snippet | undefined]>
disabled boolean
- Name
disabled- Description
Whether the combobox ignores user interaction.
- Type
boolean
data-disabled
ChipRemove
A button to remove a chip. Renders a <button> element.
disabled boolean | null false
- Name
- Description
Whether the button ignores user interaction.
- Type
boolean | null- Default
false
nativeButton boolean true
- Name
- Description
Whether the host is a native
<button>.- Type
boolean- Default
true
render Snippet<[props: HTMLButtonAttributes, state: ComboboxChipRemoveState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLButtonAttributes, state: ComboboxChipRemoveState, children: Snippet | undefined]>
disabled boolean
- Name
disabled- Description
Whether the button ignores user interaction.
- Type
boolean
data-disabled
List
A list container for the items. Renders a <div> element.
children Snippet —
- Name
- Description
The list content. Render
Combobox.Collectioninside to map the filtered items.- Type
Snippet
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxListState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxListState, children: Snippet | undefined]>
empty boolean
- Name
empty- Description
Whether the filtered list has no items.
- Type
boolean
data-empty
Portal
A portal element that moves the popup to a different part of the DOM. By default, the portal element is appended to <body>.
keepMounted boolean false
- Name
- Description
Keep the portal mounted while the popup is closed.
- Type
boolean- Default
false
container HTMLElement | ShadowRoot | null —
- Name
- Description
Element the portal is appended to.
undefineduses the parent portal ordocument.body.nullwaits and does not mount until an element or shadow root is set. There is no ref object.- Type
HTMLElement | ShadowRoot | null
render Snippet<[props: HTMLAttributes<HTMLDivElement> & Record<symbol, Attachment<HTMLDivElement>>, state: ComboboxPortalState, children: Snippet | undefined]> —
- Name
- Description
Replace the portal element. Host props include the move attachment.
- Type
Snippet<[props: HTMLAttributes<HTMLDivElement> & Record<symbol, Attachment<HTMLDivElement>>, state: ComboboxPortalState, children: Snippet | undefined]>
Backdrop
An overlay displayed beneath the popup. Renders a <div> element.
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxBackdropState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxBackdropState, children: Snippet | undefined]>
open boolean
- Name
open- Description
Whether the popup is open.
- Type
boolean
transitionStatus 'starting' | 'ending' | 'idle' | undefined
- Name
transitionStatus- Type
'starting' | 'ending' | 'idle' | undefined
data-open
data-closed
data-starting-style
data-ending-style
Positioner
Positions the popup against the input, input group or trigger. Renders a <div> element.
anchor Anchor —
- Name
- Description
An element to position the popup against. Defaults to the input group, input or trigger.
- Type
Anchor
positionMethod "absolute" | "fixed" 'absolute'
- Name
- Description
Which CSS
positionthe positioner uses.- Type
"absolute" | "fixed"- Default
'absolute'
side Side 'bottom'
- Name
- Description
Which side of the anchor to place the popup on. It can flip to avoid collisions.
- Type
Side- Default
'bottom'
align Align 'center'
- Name
- Description
How to align the popup on its side.
- Type
Align- Default
'center'
sideOffset number | OffsetFunction 0
- Name
- Description
Distance between the anchor and the popup in pixels, or a function of the anchor and positioner sizes, side and alignment.
- Type
number | OffsetFunction- Default
0
alignOffset number | OffsetFunction 0
- Name
- Description
Offset along the alignment axis in pixels, or a function like
sideOffset.- Type
number | OffsetFunction- Default
0
collisionBoundary Boundary 'clipping-ancestors'
- Name
- Description
The area the popup is confined to.
- Type
Boundary- Default
'clipping-ancestors'
collisionPadding Padding 5
- Name
- Description
Space to keep from the edge of the collision boundary.
- Type
Padding- Default
5
arrowPadding number 5
- Name
- Description
Minimum distance between the arrow and the edges of the popup.
- Type
number- Default
5
sticky boolean false
- Name
- Description
Whether the popup stays in the viewport after the anchor scrolls out of view.
- Type
boolean- Default
false
disableAnchorTracking boolean false
- Description
Whether the popup stops following layout shifts of its anchor.
- Type
boolean- Default
false
collisionAvoidance CollisionAvoidance —
- Name
- Description
How the popup avoids collisions. Dropdowns flip on the side axis and shift on the other.
- Type
CollisionAvoidance
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxPositionerState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxPositionerState, children: Snippet | undefined]>
open boolean
- Name
open- Description
Whether the popup is open.
- Type
boolean
side Side
- Name
side- Description
The side of the anchor the popup is placed on.
- Type
Side
align Align
- Name
align- Description
The alignment of the popup relative to the anchor.
- Type
Align
anchorHidden boolean
- Name
anchorHidden- Description
Whether the anchor is hidden.
- Type
boolean
empty boolean
- Name
empty- Description
Whether the filtered list has no items.
- Type
boolean
data-open
data-closed
data-anchor-hidden
data-side
data-align
data-empty
--anchor-width
--anchor-height
--available-width
--available-height
--transform-origin
Popup
A container for the list. Renders a <div> element.
initialFocus ComboboxFocusTarget —
- Name
- Description
The element to focus when the popup opens. With the input inside the popup, the default focuses the input, or the popup on touch.
- Type
ComboboxFocusTarget
finalFocus ComboboxFocusTarget —
- Name
- Description
The element to focus when the popup closes. With the input inside the popup, the default focuses the trigger. Otherwise focus stays where it is.
- Type
ComboboxFocusTarget
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxPopupState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxPopupState, children: Snippet | undefined]>
open boolean
- Name
open- Description
Whether the popup is open.
- Type
boolean
side Side
- Name
side- Description
The side of the anchor the popup is placed on.
- Type
Side
align Align
- Name
align- Description
The alignment of the popup relative to the anchor.
- Type
Align
anchorHidden boolean
- Name
anchorHidden- Description
Whether the anchor is hidden.
- Type
boolean
transitionStatus 'starting' | 'ending' | 'idle' | undefined
- Name
transitionStatus- Type
'starting' | 'ending' | 'idle' | undefined
empty boolean
- Name
empty- Description
Whether the filtered list has no items.
- Type
boolean
data-open
data-closed
data-side
data-align
data-anchor-hidden
data-empty
data-starting-style
data-ending-style
Arrow
Displays an element positioned against the anchor. Renders a <div> element.
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxArrowState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxArrowState, children: Snippet | undefined]>
open boolean
- Name
open- Description
Whether the popup is open.
- Type
boolean
side Side
- Name
side- Description
The side of the anchor the popup is placed on.
- Type
Side
align Align
- Name
align- Description
The alignment of the popup relative to the anchor.
- Type
Align
uncentered boolean
- Name
uncentered- Description
Whether the arrow cannot be centered on the anchor.
- Type
boolean
data-open
data-closed
data-side
data-align
data-uncentered
Status
Announces status messages, such as a loading state, politely to screen readers. Keep it mounted and change its children, so screen readers announce the change. Renders a <div> element.
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxStatusState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxStatusState, children: Snippet | undefined]>
Empty
Renders its children only while the filtered list is empty, and announces them politely to screen readers. Requires the items prop on the root. Keep it mounted: hide its children, not the element. Renders a <div> element.
children Snippet —
- Name
- Description
Shown while the filtered list has no items.
- Type
Snippet
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxEmptyState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxEmptyState, children: Snippet | undefined]>
Collection
Renders its snippet for each filtered item, or each item of the surrounding group. Renders no element of its own.
children* Snippet<[item: never, index: number]> —
- Name
- Description
Rendered for each filtered item, or each item of the surrounding
Combobox.Group.- Type
Snippet<[item: never, index: number]>
Row
A row of items in a grid list. Renders a <div> element.
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxRowState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxRowState, children: Snippet | undefined]>
Item
An item in the list. Renders a <div> element.
value unknown null
- Name
- Description
The value this item selects.
- Type
unknown- Default
null
index number —
- Name
- Description
The item's position in the list. Without it the item takes its position from the document order, or from
itemswhen the root isvirtualized.- Type
number
disabled boolean | null false
- Name
- Description
Whether the item ignores user interaction.
- Type
boolean | null- Default
false
nativeButton boolean false
- Name
- Description
Whether the host is a native
<button>.- Type
boolean- Default
false
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxItemState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxItemState, children: Snippet | undefined]>
disabled boolean
- Name
disabled- Description
Whether the item ignores user interaction.
- Type
boolean
selected boolean
- Name
selected- Description
Whether the item is selected.
- Type
boolean
highlighted boolean
- Name
highlighted- Description
Whether the item is highlighted.
- Type
boolean
data-selected
data-highlighted
data-disabled
ItemIndicator
Indicates whether the item is selected. Renders a <span> element.
keepMounted boolean false
- Name
- Description
Whether the indicator stays in the DOM while the item is not selected.
- Type
boolean- Default
false
render Snippet<[props: HTMLAttributes<HTMLSpanElement>, state: ComboboxItemIndicatorState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLAttributes<HTMLSpanElement>, state: ComboboxItemIndicatorState, children: Snippet | undefined]>
selected boolean
- Name
selected- Description
Whether the item is selected.
- Type
boolean
transitionStatus 'starting' | 'ending' | 'idle' | undefined
- Name
transitionStatus- Type
'starting' | 'ending' | 'idle' | undefined
data-selected
data-starting-style
data-ending-style
Group
Groups related items with their label. Renders a <div> element.
items readonly unknown[] —
- Name
- Description
The group's items, which a
Combobox.Collectioninside renders.- Type
readonly unknown[]
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxGroupState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxGroupState, children: Snippet | undefined]>
GroupLabel
The label of a group. Renders a <div> element.
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxGroupLabelState, children: Snippet | undefined]> —
- Name
- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ComboboxGroupLabelState, children: Snippet | undefined]>
Separator
A visual separator between items or groups. Renders a <div> element.
orientation "horizontal" | "vertical" 'horizontal'
- Name
- Description
The orientation of the separator.
- Type
"horizontal" | "vertical"- Default
'horizontal'
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: SeparatorState, children: Snippet | undefined]> —
- Name
- Description
Replace the default
<div>. Spreadpropsonto the host element.- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: SeparatorState, children: Snippet | undefined]>
orientation 'horizontal' | 'vertical'
- Name
orientation- Description
The orientation of the separator.
- Type
'horizontal' | 'vertical'
data-orientation
horizontal or vertical.useFilter
Matches items against a query using Intl.Collator for robust string matching.
This function is used when externally filtering items.
Pass the result to the filter prop of <Combobox.Root>.
Combobox.useFilter(options?) is a plain function, so call it in a $derived when its options change. It returns contains, startsWith and endsWith functions with the signature (item, query, itemToString?) => boolean. options takes Intl.CollatorOptions plus locale, multiple and value. In single mode, contains matches every item while the query equals the selected value's label.
useFilteredItems
Returns the internally filtered items when called inside <Combobox.Root>.
Combobox.useFilteredItems<Item>() returns { current }, a read-only array of the filtered items that updates as the query changes. Call it while a component inside the root initializes.
createItems
Normalizes items into a collection for the items prop of <Combobox.Root>, deriving each item's selection value and label before rendering.
Combobox.createItems(data, { getValue, getLabel }) accepts a flat array or an array of groups, and undefined while the data is loading. getValue returns the item's unique primitive selection value and getLabel returns its label. Items cannot have an items array, which marks a group.