Skip to main content

Combobox

A text field that suggests and completes matches from a known list as people type.

In Accessible first

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Accessible first: A long closed list, such as countries or addresses, with a label and a hint. Not a short list people can see.

  • 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:

  • Select: A compact closed list without typing.
  • Command: A search-first menu of actions.

Words​

  • Use common words. Explain any term you must use.
  • One idea per sentence. Put the action first.
  • Never blame the person.
  • Use: Continue, Change, Start, You. Avoid: Invalid, Utilise, Submit, Error code.

The labels components use, from the voice tokens:

  • content.action.commit: Continue
  • content.action.cancel: Go back
  • content.action.destroy: Delete
  • content.action.retry: Try again
  • content.action.empty-action: Start a new application

See Voice and tone for the whole voice.

Accessibility and keyboard​

KeyboardWhat happensNot
undefinedArrow 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.

Changes with theme

Accessible first 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.

PartIts token and the semantic it aliasesValue
Shared
Transition panels durationcomponent.transition.panels-durationmotion.duration.panelsvar(--transition-panels-duration)duration.moderate:200ms
Trigger
Icon sizecomponent.combobox.trigger.icon-sizesize.iconvar(--combobox-trigger-icon-size)size.20:1.25rem
Icon icon sizecomponent.combobox.trigger.icon.icon-sizesize.iconvar(--combobox-trigger-icon-icon-size)size.20:1.25rem
Icon label
Changes with theme
component.combobox.trigger.icon.labelcolor.text.mutedvar(--combobox-trigger-icon-label)Lightgray.light.500:#595959Darkgray.dark.500:#949494
Content
Cornercomponent.combobox.content.radiusradius.controlvar(--combobox-content-radius)radius.6:0.375rem
Fill
Changes with theme
component.combobox.content.backgroundcolor.surface.raisedvar(--combobox-content-background)Lightgray.light.0:#FFFFFFDarkgray.dark.100:#222222
Text
Changes with theme
component.combobox.content.labelcolor.text.primaryvar(--combobox-content-label)Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7
Shadowcomponent.combobox.content.shadowelevation.overlayvar(--combobox-content-shadow)shadow.none
Focus ring
Changes with theme
component.combobox.content.focus-ringcolor.text.primaryvar(--combobox-content-focus-ring)Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7
Heightcomponent.combobox.content.heightsize.control.defaultvar(--combobox-content-height)size.52:3.25rem
Border
Changes with theme
component.combobox.content.bordercolor.border.strongvar(--combobox-content-border)Lightgray.light.500:#595959Darkgray.dark.500:#949494
Background 2
Changes with theme
component.combobox.content.background-2color.border.strongvar(--combobox-content-background-2)Lightgray.light.500:#595959Darkgray.dark.500:#949494
List
Paddingcomponent.combobox.list.paddingcomponent-spacing-map.x1var(--combobox-list-padding)space.4:0.25rem
Item
Gapcomponent.combobox.item.gapspace.gap.defaultvar(--combobox-item-gap)space.16:1rem
Cornercomponent.combobox.item.radiusradius.badgevar(--combobox-item-radius)radius.4:0.25rem
Padding, top and bottomcomponent.combobox.item.padding-ycomponent-spacing-map.x2var(--combobox-item-padding-y)space.8:0.5rem
Padding rightcomponent.combobox.item.padding-rightcomponent-spacing-map.x8var(--combobox-item-padding-right)space.56:3.5rem
Padding leftcomponent.combobox.item.padding-leftcomponent-spacing-map.x2var(--combobox-item-padding-left)space.8:0.5rem
Text sizecomponent.combobox.item.font-sizetype.body.font-sizevar(--combobox-item-font-size)font.size.19:1.1875rem
Fill
Changes with theme
component.combobox.item.backgroundcolor.surface.sunkenvar(--combobox-item-background)Lightgray.light.100:#EDEDEDDarkgray.dark.100:#222222
Text
Changes with theme
component.combobox.item.labelcolor.text.primaryvar(--combobox-item-label)Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7
Disabled opacity disabled
when disabled
component.combobox.item.disabled-opacity-disabledopacity.disabledvar(--combobox-item-disabled-opacity-disabled)opacity.50:0.5
Icon sizecomponent.combobox.item.icon-sizesize.iconvar(--combobox-item-icon-size)size.20:1.25rem
Combobox
Icon sizecomponent.combobox.icon-sizesize.iconvar(--combobox-icon-size)size.20:1.25rem
Disabled opacitycomponent.combobox.disabled-opacityopacity.disabledvar(--combobox-disabled-opacity)opacity.50:0.5
Text
Padding, left and rightcomponent.combobox.label.padding-xcomponent-spacing-map.x2var(--combobox-label-padding-x)space.8:0.5rem
Padding, top and bottomcomponent.combobox.label.padding-ycomponent-spacing-map.x2var(--combobox-label-padding-y)space.8:0.5rem
Text sizecomponent.combobox.label.font-sizetype.caption.font-sizevar(--combobox-label-font-size)font.size.16:1rem
Text
Changes with theme
component.combobox.label.labelcolor.text.mutedvar(--combobox-label-label)Lightgray.light.500:#595959Darkgray.dark.500:#949494
Padding x 2component.combobox.label.padding-x-2space.inset.control-xvar(--combobox-label-padding-x-2)space.24:1.5rem
Font size 2component.combobox.label.font-size-2type.body.font-sizevar(--combobox-label-font-size-2)font.size.19:1.1875rem
Empty
Padding, top and bottomcomponent.combobox.empty.padding-ycomponent-spacing-map.x2var(--combobox-empty-padding-y)space.8:0.5rem
Text sizecomponent.combobox.empty.font-sizetype.body.font-sizevar(--combobox-empty-font-size)font.size.19:1.1875rem
Text
Changes with theme
component.combobox.empty.labelcolor.text.mutedvar(--combobox-empty-label)Lightgray.light.500:#595959Darkgray.dark.500:#949494
Separator
Fill
Changes with theme
component.combobox.separator.backgroundcolor.border.defaultvar(--combobox-separator-background)Lightgray.light.200:#D6D6D6Darkgray.dark.100:#222222
Chips
Gapcomponent.combobox.chips.gapcomponent-spacing-map.x2var(--combobox-chips-gap)space.8:0.5rem
Cornercomponent.combobox.chips.radiusradius.controlvar(--combobox-chips-radius)radius.6:0.375rem
Border
Changes with theme
component.combobox.chips.bordercolor.border.strongvar(--combobox-chips-border)Lightgray.light.500:#595959Darkgray.dark.500:#949494
Padding, left and rightcomponent.combobox.chips.padding-xcomponent-spacing-map.x3var(--combobox-chips-padding-x)space.20:1.25rem
Padding, top and bottomcomponent.combobox.chips.padding-ycomponent-spacing-map.x2var(--combobox-chips-padding-y)space.8:0.5rem
Text sizecomponent.combobox.chips.font-sizetype.body.font-sizevar(--combobox-chips-font-size)font.size.19:1.1875rem
Shadowcomponent.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)Lightblue.light.600:#0B4FC0Darkblue.dark.600:#8AB4F8
Focus ring focus
Changes with theme
on focus
component.combobox.chips.focus-ring-focuscolor.border.focusvar(--combobox-chips-focus-ring-focus)Lightblue.light.600:#0B4FC0Darkblue.dark.600:#8AB4F8
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 2component.combobox.chips.padding-x-2component-spacing-map.x2var(--combobox-chips-padding-x-2)space.8:0.5rem
Chip
Gapcomponent.combobox.chip.gapspace.gap.tightvar(--combobox-chip-gap)space.12:0.75rem
Cornercomponent.combobox.chip.radiusradius.badgevar(--combobox-chip-radius)radius.4:0.25rem
Fill
Changes with theme
component.combobox.chip.backgroundcolor.surface.sunkenvar(--combobox-chip-background)Lightgray.light.100:#EDEDEDDarkgray.dark.100:#222222
Padding, left and rightcomponent.combobox.chip.padding-xcomponent-spacing-map.x2var(--combobox-chip-padding-x)space.8:0.5rem
Text sizecomponent.combobox.chip.font-sizetype.caption.font-sizevar(--combobox-chip-font-size)font.size.16:1rem
Weightcomponent.combobox.chip.font-weighttype.label.font-weightvar(--combobox-chip-font-weight)font.weight.700:700
Text
Changes with theme
component.combobox.chip.labelcolor.text.primaryvar(--combobox-chip-label)Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7
Disabled opacity
when disabled
component.combobox.chip.disabled-opacityopacity.disabledvar(--combobox-chip-disabled-opacity)opacity.50:0.5
From the system
Edge
Changes with theme
color.border.default
straight from the system, through --border
Lightgray.light.200 · #D6D6D6Darkgray.dark.100 · #222222