Combobox Primitive
Use Combobox when someone needs to type to find an option. It opens a list beside the input and lets the person choose a match with the keyboard.
Anatomy
Use the Astro primitive adapter to render Combobox anatomy with the Runtime wiring included.
---import { Combobox } from "@starwind-ui/astro/combobox";---
<Combobox.Root> <Combobox.Label>Choose a framework</Combobox.Label> <Combobox.InputGroup> <Combobox.Input placeholder="Search frameworks" /> <Combobox.Trigger>Open</Combobox.Trigger> <Combobox.Clear>Clear</Combobox.Clear> </Combobox.InputGroup> <Combobox.Positioner> <Combobox.Popup> <Combobox.Empty>No results</Combobox.Empty> <Combobox.List> <Combobox.Item value="astro"> <Combobox.ItemText>Astro</Combobox.ItemText> <Combobox.ItemIndicator /> </Combobox.Item> <Combobox.Item value="react"> <Combobox.ItemText>React</Combobox.ItemText> <Combobox.ItemIndicator /> </Combobox.Item> </Combobox.List> </Combobox.Popup> </Combobox.Positioner></Combobox.Root>Use the React primitive adapter when Combobox state participates in React rendering.
import { Combobox } from "@starwind-ui/react/combobox";
export function Example() { return ( <Combobox.Root> <Combobox.Label>Choose a framework</Combobox.Label> <Combobox.InputGroup> <Combobox.Input placeholder="Search frameworks" /> <Combobox.Trigger>Open</Combobox.Trigger> <Combobox.Clear>Clear</Combobox.Clear> </Combobox.InputGroup> <Combobox.Positioner> <Combobox.Popup> <Combobox.Empty>No results</Combobox.Empty> <Combobox.List> <Combobox.Item value="astro"> <Combobox.ItemText>Astro</Combobox.ItemText> <Combobox.ItemIndicator /> </Combobox.Item> <Combobox.Item value="react"> <Combobox.ItemText>React</Combobox.ItemText> <Combobox.ItemIndicator /> </Combobox.Item> </Combobox.List> </Combobox.Popup> </Combobox.Positioner> </Combobox.Root> );}Use the Vue components to build Combobox.
<script setup lang="ts">import Combobox from "@starwind-ui/vue/combobox";</script>
<template> <Combobox.Root> <Combobox.Label>Choose a framework</Combobox.Label> <Combobox.InputGroup> <Combobox.Input placeholder="Search frameworks" /> <Combobox.Trigger>Open</Combobox.Trigger> <Combobox.Clear>Clear</Combobox.Clear> </Combobox.InputGroup> <Combobox.Positioner> <Combobox.Popup> <Combobox.Empty>No results</Combobox.Empty> <Combobox.List> <Combobox.Item value="astro"> <Combobox.ItemText>Astro</Combobox.ItemText> <Combobox.ItemIndicator /> </Combobox.Item> <Combobox.Item value="react"> <Combobox.ItemText>React</Combobox.ItemText> <Combobox.ItemIndicator /> </Combobox.Item> </Combobox.List> </Combobox.Popup> </Combobox.Positioner> </Combobox.Root></template>Use the Svelte components to build Combobox.
<script lang="ts"> import { Combobox } from "@starwind-ui/svelte/combobox";</script>
<Combobox.Root> <Combobox.Label>Choose a framework</Combobox.Label> <Combobox.InputGroup> <Combobox.Input placeholder="Search frameworks" /> <Combobox.Trigger>Open</Combobox.Trigger> <Combobox.Clear>Clear</Combobox.Clear> </Combobox.InputGroup> <Combobox.Positioner> <Combobox.Popup> <Combobox.Empty>No results</Combobox.Empty> <Combobox.List> <Combobox.Item value="astro"> <Combobox.ItemText>Astro</Combobox.ItemText> <Combobox.ItemIndicator /> </Combobox.Item> <Combobox.Item value="react"> <Combobox.ItemText>React</Combobox.ItemText> <Combobox.ItemIndicator /> </Combobox.Item> </Combobox.List> </Combobox.Popup> </Combobox.Positioner></Combobox.Root>Render the Combobox data-sw-* contract yourself, then initialize createCombobox.
<div data-sw-combobox> <div data-sw-combobox-label>Choose a framework</div> <div data-sw-combobox-input-group> <input data-sw-combobox-input role="combobox" aria-autocomplete="list" autocomplete="off" placeholder="Search frameworks" /> <button data-sw-combobox-trigger aria-haspopup="listbox">Open</button> <button data-sw-combobox-clear type="button">Clear</button> </div> <div data-sw-combobox-positioner> <div data-sw-combobox-popup role="listbox" hidden tabindex="-1"> <div data-sw-combobox-empty hidden>No results</div> <div data-sw-combobox-list> <div data-sw-combobox-item role="option" data-value="astro"> <span data-sw-combobox-item-text>Astro</span> <span data-sw-combobox-item-indicator aria-hidden="true" hidden></span> </div> <div data-sw-combobox-item role="option" data-value="react"> <span data-sw-combobox-item-text>React</span> <span data-sw-combobox-item-indicator aria-hidden="true" hidden></span> </div> </div> </div> </div></div>
<script type="module"> import { createCombobox } from "@starwind-ui/runtime/combobox";
const root = document.querySelector("[data-sw-combobox]"); if (root) { createCombobox(root); }</script>Astro, React, Vue, and Svelte components use the same underlying interactions. Each framework has its own way to read and update state. See the examples and your installed packageโs types for the available props and events. Plain HTML uses DOM events and Runtime methods.
Floating Behavior
| Fact | Value |
|---|---|
| Anchor part | inputGroup |
| Positioner part | positioner |
| Popup part | popup |
| Portal part | portal |
| Option props | side, align, sideOffset, alignOffset, avoidCollisions |
API Reference
Root
The main element that owns the Combobox Runtime instance.
- Default element
- div
- Discovery hook
- data-sw-combobox
- Role
- -
Props
open boolean -
- Description
- Controls whether Combobox is open.
- Kind
- control
- Targets
- -
- Full type
- boolean
- React
Use open for controlled state and defaultOpen for default state, and onOpenChange for change proposals.
opendefaultOpenonOpenChange
- Astro
Use open or defaultOpen for initial state, listen for starwind:open-change, and call setOpen for later updates.
opendefaultOpenstarwind:open-changesetOpen
- Runtime / HTML
Use data-default-open for initial state, listen for starwind:open-change, and call setOpen for later updates.
data-default-openstarwind:open-changesetOpen
defaultOpen boolean -
- Description
- Sets whether Combobox starts open.
- Kind
- control
- Targets
- -
- Full type
- boolean
- React
Use open for controlled state and defaultOpen for default state, and onOpenChange for change proposals.
opendefaultOpenonOpenChange
- Astro
Use open or defaultOpen for initial state, listen for starwind:open-change, and call setOpen for later updates.
opendefaultOpenstarwind:open-changesetOpen
- Runtime / HTML
Use data-default-open for initial state, listen for starwind:open-change, and call setOpen for later updates.
data-default-openstarwind:open-changesetOpen
value string | null -
- Description
- Controls the current Combobox value.
- Kind
- control
- Targets
- -
- Full type
- string | null
- React
Use value for controlled state and defaultValue for default state, and onValueChange for change proposals.
valuedefaultValueonValueChange
- Astro
Use value or defaultValue for initial state, listen for starwind:value-change, and call setValue for later updates.
valuedefaultValuestarwind:value-changesetValue
- Runtime / HTML
Use data-default-value for initial state, listen for starwind:value-change, and call setValue for later updates.
data-default-valuestarwind:value-changesetValue
defaultValue string | null -
- Description
- Sets the initial Combobox value for uncontrolled usage.
- Kind
- control
- Targets
- -
- Full type
- string | null
- React
Use value for controlled state and defaultValue for default state, and onValueChange for change proposals.
valuedefaultValueonValueChange
- Astro
Use value or defaultValue for initial state, listen for starwind:value-change, and call setValue for later updates.
valuedefaultValuestarwind:value-changesetValue
- Runtime / HTML
Use data-default-value for initial state, listen for starwind:value-change, and call setValue for later updates.
data-default-valuestarwind:value-changesetValue
inputValue string -
- Description
- Controls the input value for Combobox.
- Kind
- control
- Targets
- -
- Full type
- string
- React
Use inputValue for controlled state and defaultInputValue for default state, and onInputValueChange for change proposals.
inputValuedefaultInputValueonInputValueChange
- Astro
Use inputValue or defaultInputValue for initial state, listen for starwind:input-value-change, and call setInputValue for later updates.
inputValuedefaultInputValuestarwind:input-value-changesetInputValue
- Runtime / HTML
Use data-default-input-value for initial state, listen for starwind:input-value-change, and call setInputValue for later updates.
data-default-input-valuestarwind:input-value-changesetInputValue
defaultInputValue string -
- Description
- Controls the default input value for Combobox.
- Kind
- control
- Targets
- -
- Full type
- string
- React
Use inputValue for controlled state and defaultInputValue for default state, and onInputValueChange for change proposals.
inputValuedefaultInputValueonInputValueChange
- Astro
Use inputValue or defaultInputValue for initial state, listen for starwind:input-value-change, and call setInputValue for later updates.
inputValuedefaultInputValuestarwind:input-value-changesetInputValue
- Runtime / HTML
Use data-default-input-value for initial state, listen for starwind:input-value-change, and call setInputValue for later updates.
data-default-input-valuestarwind:input-value-changesetInputValue
autoComplete string -
- Description
- Sets the native autocomplete behavior.
- Kind
- option
- Targets
- -
- Full type
- string
disabled boolean -
- Description
- Disables the Root part.
- Kind
- option
- Targets
- -
- Full type
- boolean
filterMode "contains" | "startsWith" "contains"
- Description
- Configures the filter mode option for the Root part.
- Kind
- option
- Targets
- -
- Full type
- "contains" | "startsWith"
form string -
- Description
- Associates the control with a form element.
- Kind
- option
- Targets
- -
- Full type
- string
highlightItemOnHover boolean true
- Description
- Highlights Combobox items when the pointer moves over them.
- Kind
- option
- Targets
- -
- Full type
- boolean
locale string -
- Description
- Sets the locale used by Combobox.
- Kind
- option
- Targets
- -
- Full type
- string
modal boolean false
- Description
- Makes Combobox behave as a modal overlay.
- Kind
- option
- Targets
- -
- Full type
- boolean
name string -
- Description
- Sets the submitted form field name.
- Kind
- option
- Targets
- -
- Full type
- string
readOnly boolean false
- Description
- Marks the control as read-only.
- Kind
- option
- Targets
- -
- Full type
- boolean
required boolean -
- Description
- Marks the form control as required.
- Kind
- option
- Targets
- -
- Full type
- boolean
onInputValueChange (inputValue: string, details: ComboboxInputValueChangeDetails) => void -
- Description
- Runs when on input value change changes for Combobox.
- Kind
- callback
- Targets
- -
- Full type
- (inputValue: string, details: ComboboxInputValueChangeDetails) => void
- React
Use inputValue for controlled state and defaultInputValue for default state, and onInputValueChange for change proposals.
inputValuedefaultInputValueonInputValueChange
- Astro
Use inputValue or defaultInputValue for initial state, listen for starwind:input-value-change, and call setInputValue for later updates.
inputValuedefaultInputValuestarwind:input-value-changesetInputValue
- Runtime / HTML
Use data-default-input-value for initial state, listen for starwind:input-value-change, and call setInputValue for later updates.
data-default-input-valuestarwind:input-value-changesetInputValue
onOpenChange (open: boolean, details: ComboboxOpenChangeDetails) => void -
- Description
- Runs when Combobox opens or closes.
- Kind
- callback
- Targets
- -
- Full type
- (open: boolean, details: ComboboxOpenChangeDetails) => void
- React
Use open for controlled state and defaultOpen for default state, and onOpenChange for change proposals.
opendefaultOpenonOpenChange
- Astro
Use open or defaultOpen for initial state, listen for starwind:open-change, and call setOpen for later updates.
opendefaultOpenstarwind:open-changesetOpen
- Runtime / HTML
Use data-default-open for initial state, listen for starwind:open-change, and call setOpen for later updates.
data-default-openstarwind:open-changesetOpen
onValueChange (value: string | null, details: ComboboxValueChangeDetails) => void -
- Description
- Runs when the Combobox value changes.
- Kind
- callback
- Targets
- -
- Full type
- (value: string | null, details: ComboboxValueChangeDetails) => void
- React
Use value for controlled state and defaultValue for default state, and onValueChange for change proposals.
valuedefaultValueonValueChange
- Astro
Use value or defaultValue for initial state, listen for starwind:value-change, and call setValue for later updates.
valuedefaultValuestarwind:value-changesetValue
- Runtime / HTML
Use data-default-value for initial state, listen for starwind:value-change, and call setValue for later updates.
data-default-valuestarwind:value-changesetValue
Events
inputValueChange onInputValueChange inputValue: string
- Description
- Fires when the text input value changes for Combobox.
- DOM event
- starwind:input-value-change
- Details type
- ComboboxInputValueChangeDetails
- Timing
- before-state-commit
- Cancelable
- Yes
- Cancellation sequence
- Check internal eligibility and intent.
- Create one details object for the proposal.
- Call the Runtime callback with the details object when the controller exposes one.
- Dispatch the cancelable DOM event with the same details object, including when the callback canceled it.
- Read details.isCanceled, including cancellation caused by preventDefault().
- Apply the accepted state.
- Notify Runtime subscribers and other accepted-only observers.
openChange onOpenChange open: boolean
- Description
- Fires when Combobox opens or closes.
- DOM event
- starwind:open-change
- Details type
- ComboboxOpenChangeDetails
- Timing
- before-state-commit
- Cancelable
- Yes
- Cancellation sequence
- Check internal eligibility and intent.
- Create one details object for the proposal.
- Call the Runtime callback with the details object when the controller exposes one.
- Dispatch the cancelable DOM event with the same details object, including when the callback canceled it.
- Read details.isCanceled, including cancellation caused by preventDefault().
- Apply the accepted state.
- Notify Runtime subscribers and other accepted-only observers.
valueChange onValueChange value: string | null
- Description
- Fires when the value changes for Combobox.
- DOM event
- starwind:value-change
- Details type
- ComboboxValueChangeDetails
- Timing
- before-state-commit
- Cancelable
- Yes
- Cancellation sequence
- Check internal eligibility and intent.
- Create one details object for the proposal.
- Call the Runtime callback with the details object when the controller exposes one.
- Dispatch the cancelable DOM event with the same details object, including when the callback canceled it.
- Read details.isCanceled, including cancellation caused by preventDefault().
- Apply the accepted state.
- Notify Runtime subscribers and other accepted-only observers.
State
inputValue string inputValue / defaultInputValue
- Description
- Tracks the current text input value for Combobox.
- Initial attribute
- data-default-input-value
- Runtime getter
- getInputValue
- Runtime setter
- setInputValue
- React
Use inputValue for controlled state and defaultInputValue for default state, and onInputValueChange for change proposals.
inputValuedefaultInputValueonInputValueChange
- Astro
Use inputValue or defaultInputValue for initial state, listen for starwind:input-value-change, and call setInputValue for later updates.
inputValuedefaultInputValuestarwind:input-value-changesetInputValue
- Runtime / HTML
Use data-default-input-value for initial state, listen for starwind:input-value-change, and call setInputValue for later updates.
data-default-input-valuestarwind:input-value-changesetInputValue
open boolean open / defaultOpen
- Description
- Tracks whether Combobox is open.
- Initial attribute
- data-default-open
- Runtime getter
- getOpen
- Runtime setter
- setOpen
- React
Use open for controlled state and defaultOpen for default state, and onOpenChange for change proposals.
opendefaultOpenonOpenChange
- Astro
Use open or defaultOpen for initial state, listen for starwind:open-change, and call setOpen for later updates.
opendefaultOpenstarwind:open-changesetOpen
- Runtime / HTML
Use data-default-open for initial state, listen for starwind:open-change, and call setOpen for later updates.
data-default-openstarwind:open-changesetOpen
value string | null value / defaultValue
- Description
- Tracks the current Combobox value.
- Initial attribute
- data-default-value
- Runtime getter
- getValue
- Runtime setter
- setValue
- React
Use value for controlled state and defaultValue for default state, and onValueChange for change proposals.
valuedefaultValueonValueChange
- Astro
Use value or defaultValue for initial state, listen for starwind:value-change, and call setValue for later updates.
valuedefaultValuestarwind:value-changesetValue
- Runtime / HTML
Use data-default-value for initial state, listen for starwind:value-change, and call setValue for later updates.
data-default-valuestarwind:value-changesetValue
Data Attributes
Runtime hooks
State
Metadata
Label
Text label associated with Combobox.
- Default element
- div
- Discovery hook
- data-sw-combobox-label
- Role
- -
Data Attributes
Runtime hooks
Input Group
Groups the input controls for Combobox.
- Default element
- div
- Discovery hook
- data-sw-combobox-input-group
- Role
- -
Data Attributes
Runtime hooks
Input
The native input synchronized by Combobox.
- Default element
- input
- Discovery hook
- data-sw-combobox-input
- Role
- combobox
Data Attributes
Runtime hooks
Trigger
The control that opens, closes, or targets the Combobox content.
- Default element
- button
- Discovery hook
- data-sw-combobox-trigger
- Role
- -
Props
asChild boolean -
- Description
- Merges behavior onto your child element instead of rendering the default Trigger element.
- Kind
- rendering
- Targets
- clear, trigger
- Full type
- boolean
Data Attributes
Runtime hooks
State
Icon
Decorative icon rendered by Combobox.
- Default element
- span
- Discovery hook
- data-sw-combobox-icon
- Role
- -
Data Attributes
Runtime hooks
Clear
Clears the current Combobox value.
- Default element
- button
- Discovery hook
- data-sw-combobox-clear
- Role
- -
Props
asChild boolean -
- Description
- Merges behavior onto your child element instead of rendering the default Clear element.
- Kind
- rendering
- Targets
- clear, trigger
- Full type
- boolean
Data Attributes
Runtime hooks
Value
Displays the current Combobox value.
- Default element
- span
- Discovery hook
- data-sw-combobox-value
- Role
- -
Data Attributes
Runtime hooks
Hidden Input
The hidden native input synchronized by Combobox.
- Default element
- input
- Discovery hook
- data-sw-combobox-hidden-input
- Role
- -
Data Attributes
Runtime hooks
Portal
Moves Combobox overlay content to the document body when needed.
- Default element
- div
- Discovery hook
- data-sw-combobox-portal
- Role
- -
Data Attributes
Runtime hooks
Metadata
Positioner
Positions the Combobox content relative to its trigger.
- Default element
- div
- Discovery hook
- data-sw-combobox-positioner
- Role
- -
Props
side "top" | "right" | "bottom" | "left" "bottom"
- Description
- Sets the preferred side for Combobox content.
- Kind
- option
- Targets
- positioner, popup
- Full type
- "top" | "right" | "bottom" | "left"
align "start" | "center" | "end" "start"
- Description
- Sets how Combobox content aligns to its trigger.
- Kind
- option
- Targets
- positioner, popup
- Full type
- "start" | "center" | "end"
sideOffset number 4
- Description
- Sets the distance between Combobox content and its trigger.
- Kind
- option
- Targets
- positioner, popup
- Full type
- number
alignOffset number 0
- Description
- Adjusts the cross-axis alignment offset for Combobox content.
- Kind
- option
- Targets
- positioner, popup
- Full type
- number
avoidCollisions boolean true
- Description
- Allows Combobox content to shift or flip to stay visible.
- Kind
- option
- Targets
- positioner, popup
- Full type
- boolean
Data Attributes
Runtime hooks
Metadata
Popup
The floating content container for Combobox.
- Default element
- div
- Discovery hook
- data-sw-combobox-popup
- Role
- listbox
Props
side "top" | "right" | "bottom" | "left" "bottom"
- Description
- Sets the preferred side for Combobox content.
- Kind
- option
- Targets
- positioner, popup
- Full type
- "top" | "right" | "bottom" | "left"
align "start" | "center" | "end" "start"
- Description
- Sets how Combobox content aligns to its trigger.
- Kind
- option
- Targets
- positioner, popup
- Full type
- "start" | "center" | "end"
sideOffset number 4
- Description
- Sets the distance between Combobox content and its trigger.
- Kind
- option
- Targets
- positioner, popup
- Full type
- number
alignOffset number 0
- Description
- Adjusts the cross-axis alignment offset for Combobox content.
- Kind
- option
- Targets
- positioner, popup
- Full type
- number
avoidCollisions boolean true
- Description
- Allows Combobox content to shift or flip to stay visible.
- Kind
- option
- Targets
- positioner, popup
- Full type
- boolean
Data Attributes
Runtime hooks
State
Metadata
Empty
Content shown when Combobox has no matching items.
- Default element
- div
- Discovery hook
- data-sw-combobox-empty
- Role
- -
Data Attributes
Runtime hooks
List
The list of selectable Combobox items.
- Default element
- div
- Discovery hook
- data-sw-combobox-list
- Role
- -
Data Attributes
Runtime hooks
Group
Groups related Combobox items.
- Default element
- div
- Discovery hook
- data-sw-combobox-group
- Role
- group
Data Attributes
Runtime hooks
Group Label
Labels a group of Combobox items.
- Default element
- div
- Discovery hook
- data-sw-combobox-group-label
- Role
- -
Data Attributes
Runtime hooks
Item
An interactive item inside the Combobox collection.
- Default element
- div
- Discovery hook
- data-sw-combobox-item
- Role
- option
Data Attributes
Runtime hooks
Metadata
Item Text
Text content for a Combobox item.
- Default element
- span
- Discovery hook
- data-sw-combobox-item-text
- Role
- -
Data Attributes
Runtime hooks
Item Indicator
Shows the selected state for a Combobox item.
- Default element
- span
- Discovery hook
- data-sw-combobox-item-indicator
- Role
- -
Data Attributes
Runtime hooks
State
Separator
Separates groups of Combobox items.
- Default element
- div
- Discovery hook
- data-sw-combobox-separator
- Role
- separator
Data Attributes
Runtime hooks
Runtime API
- Factory
createCombobox- Import
@starwind-ui/runtime/combobox- Root hook
- root
data-sw-combobox - Option props
- autoComplete, defaultInputValue, defaultOpen, defaultValue, disabled, filterMode, form, highlightItemOnHover, inputValue, locale, modal, name, open, readOnly, required, value
Option Lifecycles
| Option | Lifecycle |
|---|---|
| autoComplete | setter-backed |
| defaultInputValue | constructor-only |
| defaultOpen | constructor-only |
| defaultValue | constructor-only |
| disabled | setter-backed |
| filterMode | constructor-only |
| form | setter-backed |
| highlightItemOnHover | constructor-only |
| inputValue | setter-backed |
| locale | constructor-only |
| modal | constructor-only |
| name | setter-backed |
| open | setter-backed |
| readOnly | constructor-only |
| required | setter-backed |
| value | setter-backed |
Runtime Setters
Form Participation
| Fact | Value |
|---|---|
| Form props | autoComplete, form, name, required, value |
| Hidden input | hiddenInput (text) |
| Field integration | Yes |
Related Styled Components
Changelog
View version history v1.3.0 10 releases
v1.3.0
- Combobox popups keep the direction of the input when they move into a portal, including inside a section with the opposite `dir`.
- When you close the list with Escape or by choosing an item, Combobox now returns focus to the input without scrolling the page. Before, in Safari, the page could jump back to the input after you scrolled.
- A click during the Combobox popup close animation now goes to the page below the popup. Before, the closing popup caught the click, so a quick click on a control under it did nothing.
- In Vue, Combobox now shows the item label in the input when the parent sets a value after the first render, with `v-model` or a one-way `value` prop. Before, the input stayed empty.
- In Vue, this Primitive now uses the same `asChild` child handling as the other Vue Primitives. Its public API is unchanged. An invalid `asChild` child now gives one shorter error message.
- In Vue, `ComboboxContextValue` no longer has `element`, `mounted` or `registerPortal()`. The state fields, such as `open` and `value`, stay.
- Combobox now closes when you press Tab right after the click that opened it. Before, focus left the list, but it stayed open.
- In Svelte, the server HTML of `Combobox.Trigger` now prints `data-state`, and a disabled Trigger or Clear prints `aria-disabled`, as in the other frameworks.
- In Svelte, `data-default-value` and `data-default-input-value` now come only from the `defaultValue` and `defaultInputValue` props.
- In Vue, this component now needs Vue 3.5.21 or newer.
- Internal code cleanup, such as unused code and import order. This cleanup does not change behavior.
v1.2.0
- Combobox now closes when focus leaves it. Before, the list stayed open after you pressed Tab or Shift+Tab. The list stays open while focus moves between the input, the trigger, and the clear button. The close uses the new `focus-out` reason. Call `cancel()` in `onOpenChange` to keep the list open.
- Combobox now sends its events in the same order in every framework. Pressing an item sends the value change, then the input text change with the `item-press` reason, then the open change. Clearing sends the value change, then the input text change to `""` with the `clear` reason. You can cancel the input text change in every framework.
- When you cancel a typed change, the input text goes back to the previous text. This now also works in Astro.
- When your code controls `value` and keeps it without calling `cancel()`, the input text now shows the label of the value you kept. When your code controls `inputValue`, typing in the middle of the text keeps the caret in place. A form reset keeps a value that your code controls.
- Fixed a Combobox with a `ComboboxTrigger` that you added yourself. Before, only the trigger inside the input rendered by `ComboboxInput` worked. Now every trigger opens and closes the list and shows the open and disabled state.
- Focus now goes back to a trigger after a close only when you have not moved on. Before, this could close a Combobox that you had just opened.
- Styled `ComboboxClear` with `asChild` now uses your child as the button. Before, the default icon made a button inside a button in Vue and React, and a hydration mismatch in Nuxt. Add your own icon to the child if you want one.
- In React, Combobox now opens on the first focus of its input, as it does in Astro, Vue, and Svelte, and it keeps `data-value` on the root when a parent changes the value while the list is closed.
- Fixed a Combobox with more than one `ComboboxClear`. Before, only the first one worked. Pressing another one did not clear the selection or the text, and inside the input group it opened the list. Now every `ComboboxClear` clears the selection and the text, and each one shows the disabled state.
- In Svelte, a Combobox that gets its props through a spread, such as `{...props}`, now shows the new label when your state changes `value`. Before, the text field kept the old label while the form sent the new value.
- In Svelte, `Combobox.Root` now renders option attributes such as `data-modal` and `data-filter-mode`, and its first render shows the open state.
- In Svelte, the Primitive `Combobox.Clear` no longer adds an English `aria-label`. Set your own label.
- In React, Combobox now shows the selected label when your own component renders the items. If your items load later, a value has no label until someone opens the list and picks an item.
- If you use Runtime directly and your items render only when the list opens, pass the new `resolveValueText` option to `createCombobox`. It returns the label for a selected value whose item is not rendered.
- In Astro, an attribute that you set on a Combobox part now wins over the part's own default for the same attribute, such as `role` or `aria-label`.
- In Svelte, a defined `value`, `inputValue`, or `open` that you pass when Combobox mounts now stays under your control, as in React and Vue. To change it, use `bind:` or update your state in the change callback. A form reset keeps it. If you pass `undefined` at mount, Combobox keeps its own state.
- In Svelte, `Combobox.Trigger` and `Combobox.Clear` still need a button in `child`. With another element they do nothing, and they now log a console error in production as well as in development.
- In Vue, the template ref of the Combobox root no longer has the undocumented methods `open`, `close`, `updatePosition`, `getValue`, and `setValue`. It exposes only `element`. Use `v-model` on the root instead.
- In React, Select and Combobox inside a `Field` with a `name` now send their value when the form submits, and they call `onValueChange`, `onOpenChange`, and `onInputValueChange`. Before, the form often left the value out, and the callbacks did not run.
v1.1.3
- A `required` Combobox now stops a plain HTML form from submitting when no option is selected. The browser shows its message and puts focus in the Combobox input. The list stays closed so it does not cover the message. Before, the empty form submitted, and no message showed.
- A Combobox without `required` still lets the Enter key submit the form as before.
v1.1.2
- Fixed form resets overwriting newer input or changing the value after a reset was canceled. React restores input text after Escape, and Vue restores it after a canceled input change.
- Reduced background work when a React page uses multiple menus, tooltips, or other portals.
- Fixed nested Svelte overlays inside a dialog appearing behind their parent or failing to receive clicks.
- Reduced background work when a Vue page uses multiple menus, tooltips, or other portals.
- Fixed nested overlays appearing behind their parent in Vue and Svelte. Overlays can now render under the document body; if custom CSS or DOM queries require them to stay inside a parent, set a portal container or add `data-floating-root` to that parent.
- Reduced the JavaScript loaded by Combobox when it is used without Field.
- Fixed React 18 retaining removed popup elements when the parent component stays mounted.
- Reduced repeated JavaScript when Astro Combobox is used with other Starwind components.
- Reduced JavaScript used by Svelte Combobox. Element props, event handlers, and refs keep the same behavior.
v1.1.1
- Group headings are now linked to their groups with `aria-labelledby`, so screen readers announce the name of each group.
v1.1.0
- Added `container` and `disabled` to the Portal part. `container` sets the element that holds the popup, and `disabled` keeps the popup in place. Portals now place nested popups in the same way every time, and they show their placement in data attributes.
v1.0.0
- This Primitive is now stable at version `1.0.0`. Its API and behavior stay the same as in the previous release.
v0.1.2
- The React Primitive files that the CLI copies into your project are now marked with `"use client"`, so they stay client components in React server frameworks.
- In React, you can cancel a change from its change callback or DOM event before it applies. React then shows only the changes that apply.
- In React, you can now cancel the value and input text changes that Combobox commands make.
v0.1.1
- When `modal` is set, the page behind the Combobox no longer scrolls while the list is open.
v0.1.0
- First release. Combobox filters and selects items and supports keyboard navigation. It places its list next to the input and sends its value with the form.