Combobox
Picks one value from a long list by typing to filter it: a country, a person, a repository. It has Input's box with a caret, and opens Select's list under the field; the arrow keys move through the matches and Enter picks one.
Preview
Usage
When to use
- Pick one value from a list too long to scan, by typing part of it: a country, a person, a repository.
- A list whose options the user already knows by name.
When not to use
- A short list of options. Use Select, or RadioGroup to show them all.
- Free text. Use Input.
- Several values. Use Tokenizer, or Checkbox for a short list.
Platform support
What each platform has, from the spec. A selected platform is highlighted.
| Name | Web | iOS | Android | Note |
|---|---|---|---|---|
| defaultValue | Yes | Deferred | Deferred | Not generated for iOS and Android. |
| value | Yes | Yes | Yes | |
| onValueChange | Yes | Yes | Yes | |
| open | Yes | Yes | Yes | |
| defaultOpen | Yes | Yes | Yes | |
| onOpenChange | Yes | Yes | Yes | |
| placeholder | Yes | Yes | Yes | |
| emptyText | Yes | Yes | Yes | |
| size | Yes | Yes | Yes | |
| disabled | Yes | Yes | Yes | |
| name | Yes | No | No | Only on web. Not generated for iOS and Android. |
| invalid | Yes | Yes | Yes | |
| leadingIcon | No | Yes | Yes | Only on iOS, Android. |
| options | No | Yes | Yes | Only on iOS, Android. |
| sheetTitle | No | Yes | Yes | Only on iOS, Android. |
| sheetSize | No | Yes | Yes | Only on iOS, Android. |
| query | No | Yes | Yes | Only on iOS, Android. |
| onQueryChange | No | Yes | Yes | Only on iOS, Android. |
| value of keyboard: Type | Yes | Deferred | Deferred | |
| value of keyboard: ArrowDown, ArrowUp | Yes | Deferred | Deferred | |
| value of keyboard: Enter | Yes | Deferred | Deferred | |
| value of keyboard: Escape | Yes | Deferred | Deferred | |
| value of keyboard: Tab | Yes | Deferred | Deferred |
Variants
size
Field height from size-element-*. Match the Input or Button next to it: md in forms, sm only in dense mouse-first UI, lg or xl for the main field of a screen and on touch-first screens.
Examples
Country
Groups
A heading over each group; a disabled option stays in the list but can't be picked.
Do and don't
Do
- Use it for lists too long to scan, where users know what they look for.
- Write emptyText that says what was not found: No country found.
- Put it in a Field with a visible label.
Don't
- Don't use it for a short list; use Select or RadioGroup.
- Don't use it for free text; use Input.
- Don't use it for several values; use Tokenizer or Checkbox.
Props
| Name | Type | Values | Default | Description |
|---|---|---|---|---|
| defaultValue | string | - | - | The value picked on first render, when you don't control it. Not generated for iOS and Android. |
| value | string | - | - | The picked value, when you control it. Pair it with onValueChange. |
| onValueChange | function | - | - | Called with the value of the option the user picks. |
| open | boolean | - | - | Whether the list is open, when you control it. Pair it with onOpenChange. |
| defaultOpen | boolean | - | false | Opens the list on first render. |
| onOpenChange | function | - | - | Called with true or false when the list opens or closes. |
| placeholder | string | - | - | What to type, shown while the field is empty: Search countries. Not a label. |
| emptyText required | string | - | - | What the list says when the text matches no option: No country found. |
| size | enum | sm | md | lg | xl | md | Field height from size-element-*. Match the Input or Button next to it: md in forms, sm only in dense mouse-first UI, lg or xl for the main field of a screen and on touch-first screens. |
| disabled | boolean | - | false | Can't be focused or opened; the neutral disabled look. |
| name | string | - | - | Form name. The picked value is submitted under it. Only on web. Not generated for iOS and Android. |
| invalid | boolean | - | false | Sets aria-invalid, which draws the danger border. Pair it with error text in color-text-danger linked through aria-describedby. |
| leadingIcon | node | - | - | Optional decorative icon before the value in the trigger, such as a globe or search icon: 16px in sm, md and lg, 20px in xl. Hidden from screen readers. Native only. Only on iOS, Android. |
| options required | ComboboxOption[] | - | - | The options of the list, in order: each has a value, a label and optional disabled. They open in a bottom Sheet, filtered by the search input. Native only; the web builds them from ComboboxItem. Only on iOS, Android. |
| sheetTitle required | string | - | - | The name of the Sheet that holds the search input and options. Shown as its title and read by assistive technology. Native only. Only on iOS, Android. |
| sheetSize | enum | sm | md | lg | lg | How tall the Sheet may grow: lg by default so the soft keyboard and filtered list both fit comfortably. Native only. Only on iOS, Android. |
| query | string | - | - | Controlled search query inside the Sheet. Omit for built-in local case-insensitive substring filtering; pair with onQueryChange for custom or API filtering. Native only. Only on iOS, Android. |
| onQueryChange | function | - | - | Called with the search text as the user types in the Sheet. When provided, the app owns filtering of options. Native only. Only on iOS, Android. |
Slots
| Name | Required | Description |
|---|---|---|
| items | yes | ComboboxItem elements (value, the text, optional textValue and disabled), or ComboboxGroup elements with a heading around them. Keep them direct children. |
Anatomy
| Part | Description |
|---|---|
| root | Combobox: the field and its list. |
| group | The field box: Input's sunken fill, control border, corners and sizes, with the text field and the caret. It shows the field's focus ring, disabled look and danger border. |
| groupIcon | Tabler CaretDown at the end, 16px (20px in xl), secondary. |
| placeholder | Placeholder text while nothing is picked or typed. |
| content | The list under the field, as wide as it: Select's raised surface. It scrolls past 288px. |
| item | An option, Select's option look: the md control height, inner corners, the neutral hover overlay when highlighted. |
| indicator | Tabler Check, 16px, at the end of the picked option. |
| groupLabel | The heading of a ComboboxGroup, Select's group heading. |
| empty | emptyText when nothing matches: 14px secondary text. |
Accessibility
Role: combobox
| Keys | Action |
|---|---|
| Type | Filters the options to those that contain the text, and opens the list. |
| ArrowDown, ArrowUp | Opens the list, or moves through the matches; disabled options are skipped. |
| Enter | Picks the highlighted option and closes the list. |
| Escape | Closes the list and puts back the picked option's text. |
| Tab | Closes the list and moves on. |
- The field is a combobox with aria-expanded, aria-controls and aria-autocomplete="list"; the highlighted option is its aria-activedescendant, so focus stays in the field.
- Name it with a Field label or aria-label. The options are read with their selected state; a group is named by its heading.
- When no option matches, the list says emptyText.
- With name, the picked value is submitted under it in a hidden input.
Install
npx werewolf-ui add comboboxRun npx werewolf-ui init once in your app before adding components. Init sets up tokens, their CSS import and agent rules. Add installs this component and its dependencies while preserving your theme. See Installation for requirements and the alternative registry setup.