Combobox
A text field that suggests and completes matches from a known list as people type.
In Dense data
See it live
npm run storybookWhen to use it
In Dense data: Picks an asset or a user from thousands.
- Use it when: A long, closed list: countries, addresses, people, tags.
- Not when: Searching a whole site, or a short list people can see at once.
Instead:
Words
- Lead with the object, then the state: "Alert 2041 contained."
- Use numbers, not words for numbers.
- One verb per button. No "please", no exclamation marks.
- Use: Investigate, Filter, Assign, Escalated, Resolved. Avoid: Oops, Awesome, Please, Simply.
The labels components use, from the voice tokens:
content.action.commit: Savecontent.action.cancel: Cancelcontent.action.destroy: Deletecontent.action.retry: Retrycontent.action.empty-action: Change filters
See Voice and tone for the whole voice.
Accessibility and keyboard
| Keyboard | What happens | Not |
|---|---|---|
| undefined | Arrow keys move through suggestions; Enter picks; Escape closes. | undefined |
Test before you ship:
- It is a combobox; the open state and the active option are announced. undefined
Use it in code
npx open-ds add combobox
The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.
Tokens it reads
Combobox reads 55 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Combobox's tokens to change Combobox alone.
Dense data decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.
| Part | Its token and the semantic it aliases | Value |
|---|---|---|
| Shared | ||
| Transition panels duration | component.transition.panels-durationmotion.duration.panelsvar(--transition-panels-duration) | duration.fast:120ms |
| Trigger | ||
| Icon size | component.combobox.trigger.icon-sizesize.iconvar(--combobox-trigger-icon-size) | size.16:1rem |
| Icon icon size | component.combobox.trigger.icon.icon-sizesize.iconvar(--combobox-trigger-icon-icon-size) | size.16:1rem |
| Icon label Changes with theme | component.combobox.trigger.icon.labelcolor.text.mutedvar(--combobox-trigger-icon-label) | Lightslate.light.600:#535D6DDarkslate.dark.400:#969FAD |
| Content | ||
| Corner | component.combobox.content.radiusradius.controlvar(--combobox-content-radius) | radius.2:0.125rem |
| Fill Changes with theme | component.combobox.content.backgroundcolor.surface.raisedvar(--combobox-content-background) | Lightslate.light.0:#FFFFFFDarkslate.dark.100:#262D38 |
| Text Changes with theme | component.combobox.content.labelcolor.text.primaryvar(--combobox-content-label) | Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA |
| Shadow Changes with theme | component.combobox.content.shadowelevation.overlayvar(--combobox-content-shadow) | Lightshadow.overlayDarkshadow.overlay-dark |
| Focus ring Changes with theme | component.combobox.content.focus-ringcolor.text.primaryvar(--combobox-content-focus-ring) | Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA |
| Height | component.combobox.content.heightsize.control.defaultvar(--combobox-content-height) | size.32:2rem |
| Border Changes with theme | component.combobox.content.bordercolor.border.strongvar(--combobox-content-border) | Lightslate.light.500:#6B7585Darkslate.dark.400:#969FAD |
| Background 2 Changes with theme | component.combobox.content.background-2color.border.strongvar(--combobox-content-background-2) | Lightslate.light.500:#6B7585Darkslate.dark.400:#969FAD |
| List | ||
| Padding | component.combobox.list.paddingcomponent-spacing-map.x1var(--combobox-list-padding) | space.4:0.25rem |
| Item | ||
| Gap | component.combobox.item.gapspace.gap.defaultvar(--combobox-item-gap) | space.8:0.5rem |
| Corner | component.combobox.item.radiusradius.badgevar(--combobox-item-radius) | radius.0:0rem |
| Padding, top and bottom | component.combobox.item.padding-ycomponent-spacing-map.x2var(--combobox-item-padding-y) | space.8:0.5rem |
| Padding right | component.combobox.item.padding-rightcomponent-spacing-map.x8var(--combobox-item-padding-right) | space.32:2rem |
| Padding left | component.combobox.item.padding-leftcomponent-spacing-map.x2var(--combobox-item-padding-left) | space.8:0.5rem |
| Text size | component.combobox.item.font-sizetype.body.font-sizevar(--combobox-item-font-size) | font.size.14:0.875rem |
| Fill Changes with theme | component.combobox.item.backgroundcolor.surface.sunkenvar(--combobox-item-background) | Lightslate.light.100:#EEF1F5Darkslate.dark.100:#262D38 |
| Text Changes with theme | component.combobox.item.labelcolor.text.primaryvar(--combobox-item-label) | Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA |
| Disabled opacity disabled when disabled | component.combobox.item.disabled-opacity-disabledopacity.disabledvar(--combobox-item-disabled-opacity-disabled) | opacity.40:0.4 |
| Icon size | component.combobox.item.icon-sizesize.iconvar(--combobox-item-icon-size) | size.16:1rem |
| Combobox | ||
| Icon size | component.combobox.icon-sizesize.iconvar(--combobox-icon-size) | size.16:1rem |
| Disabled opacity | component.combobox.disabled-opacityopacity.disabledvar(--combobox-disabled-opacity) | opacity.40:0.4 |
| Text | ||
| Padding, left and right | component.combobox.label.padding-xcomponent-spacing-map.x2var(--combobox-label-padding-x) | space.8:0.5rem |
| Padding, top and bottom | component.combobox.label.padding-ycomponent-spacing-map.x2var(--combobox-label-padding-y) | space.8:0.5rem |
| Text size | component.combobox.label.font-sizetype.caption.font-sizevar(--combobox-label-font-size) | font.size.12:0.75rem |
| Text Changes with theme | component.combobox.label.labelcolor.text.mutedvar(--combobox-label-label) | Lightslate.light.600:#535D6DDarkslate.dark.400:#969FAD |
| Padding x 2 | component.combobox.label.padding-x-2space.inset.control-xvar(--combobox-label-padding-x-2) | space.12:0.75rem |
| Font size 2 | component.combobox.label.font-size-2type.body.font-sizevar(--combobox-label-font-size-2) | font.size.14:0.875rem |
| Empty | ||
| Padding, top and bottom | component.combobox.empty.padding-ycomponent-spacing-map.x2var(--combobox-empty-padding-y) | space.8:0.5rem |
| Text size | component.combobox.empty.font-sizetype.body.font-sizevar(--combobox-empty-font-size) | font.size.14:0.875rem |
| Text Changes with theme | component.combobox.empty.labelcolor.text.mutedvar(--combobox-empty-label) | Lightslate.light.600:#535D6DDarkslate.dark.400:#969FAD |
| Separator | ||
| Fill Changes with theme | component.combobox.separator.backgroundcolor.border.defaultvar(--combobox-separator-background) | Lightslate.light.200:#DDE2EADarkslate.dark.100:#262D38 |
| Chips | ||
| Gap | component.combobox.chips.gapcomponent-spacing-map.x2var(--combobox-chips-gap) | space.8:0.5rem |
| Corner | component.combobox.chips.radiusradius.controlvar(--combobox-chips-radius) | radius.2:0.125rem |
| Border Changes with theme | component.combobox.chips.bordercolor.border.strongvar(--combobox-chips-border) | Lightslate.light.500:#6B7585Darkslate.dark.400:#969FAD |
| Padding, left and right | component.combobox.chips.padding-xcomponent-spacing-map.x3var(--combobox-chips-padding-x) | space.12:0.75rem |
| Padding, top and bottom | component.combobox.chips.padding-ycomponent-spacing-map.x2var(--combobox-chips-padding-y) | space.8:0.5rem |
| Text size | component.combobox.chips.font-sizetype.body.font-sizevar(--combobox-chips-font-size) | font.size.14:0.875rem |
| Shadow | component.combobox.chips.shadowelevation.cardvar(--combobox-chips-shadow) | shadow.none |
| Border focus Changes with theme on focus | component.combobox.chips.border-focuscolor.border.focusvar(--combobox-chips-border-focus) | Lightviolet.light.600:#4B3FD9Darkviolet.dark.600:#A9A3F6 |
| Focus ring focus Changes with theme on focus | component.combobox.chips.focus-ring-focuscolor.border.focusvar(--combobox-chips-focus-ring-focus) | Lightviolet.light.600:#4B3FD9Darkviolet.dark.600:#A9A3F6 |
| Border invalid Changes with theme when invalid | component.combobox.chips.border-invalidcolor.status.dangervar(--combobox-chips-border-invalid) | Lightred.light.600:#C42B2BDarkred.dark.600:#F28B8B |
| Focus ring invalid Changes with theme when invalid | component.combobox.chips.focus-ring-invalidcolor.status.dangervar(--combobox-chips-focus-ring-invalid) | Lightred.light.600:#C42B2BDarkred.dark.600:#F28B8B |
| Padding x 2 | component.combobox.chips.padding-x-2component-spacing-map.x2var(--combobox-chips-padding-x-2) | space.8:0.5rem |
| Chip | ||
| Gap | component.combobox.chip.gapspace.gap.tightvar(--combobox-chip-gap) | space.4:0.25rem |
| Corner | component.combobox.chip.radiusradius.badgevar(--combobox-chip-radius) | radius.0:0rem |
| Fill Changes with theme | component.combobox.chip.backgroundcolor.surface.sunkenvar(--combobox-chip-background) | Lightslate.light.100:#EEF1F5Darkslate.dark.100:#262D38 |
| Padding, left and right | component.combobox.chip.padding-xcomponent-spacing-map.x2var(--combobox-chip-padding-x) | space.8:0.5rem |
| Text size | component.combobox.chip.font-sizetype.caption.font-sizevar(--combobox-chip-font-size) | font.size.12:0.75rem |
| Weight | component.combobox.chip.font-weighttype.label.font-weightvar(--combobox-chip-font-weight) | font.weight.500:500 |
| Text Changes with theme | component.combobox.chip.labelcolor.text.primaryvar(--combobox-chip-label) | Lightslate.light.900:#161B23Darkslate.dark.900:#F7F8FA |
| Disabled opacity when disabled | component.combobox.chip.disabled-opacityopacity.disabledvar(--combobox-chip-disabled-opacity) | opacity.40:0.4 |
| From the system | ||
| Edge Changes with theme | color.border.default straight from the system, through --border | Lightslate.light.200 · #DDE2EADarkslate.dark.100 · #262D38 |