Mushilu-San UI

Search components

PlaygroundStorybookGitHub
Overlays

Combobox

A button that opens a searchable list of options to choose one value from.

Selector: mui-combobox

Import
import { Combobox, ComboboxItem } from '@mushilu-san/ui/overlays';
PreviewCode

Loading example…

Overview

Combobox shows the chosen value in a trigger button and opens a role="listbox" panel of mui-combobox-item options. value is a two-way model that holds the chosen item value.

Escape closes the panel and returns focus to the trigger. Use it when the list is too long for a native select.

When to use

  • Choosing one value from a long list, such as a country, a user or a product.
  • Lists where users know part of the name.

When not to use

  • A short fixed list. Use a select, which is simpler and works natively on phones. Use Select instead.
  • Running a command. Use a command palette. Use Command instead.

Guidelines

Do

  • Give the trigger a label that names the field.
  • Show the chosen value in the trigger so the choice is visible.

Don't

  • Do not use a combobox for two or three options. Use radio buttons or a select.

Accessibility

Roles and attributes

ElementRoleNotes
triggerbutton with aria-haspopup="listbox"aria-expanded follows the panel.
panellistboxOptions are role="option", with aria-selected on the chosen one.

Keyboard

KeysAction
EnterSpaceOpens the panel on the trigger.
EscapeCloses the panel and returns focus to the trigger.
  • Label the trigger with the field name. The chosen value is announced when the panel closes.

API

Combobox

Selector: mui-combobox

NameTypeDefaultDescription
placeholderstring'Select…' Text shown in the trigger when nothing is chosen. Default `Select…`.
disabledbooleanfalse Disables the trigger. Accepts attribute presence, e.g. <… disabled>.
NameTypeDefaultDescription
valuestring'' Value of the chosen item. Two-way bindable with `[(value)]`.
NameTypeDescription
openedvoid Emits when the panel opens.
closedvoid Emits when the panel closes.

CSS parts

  • ::part(list)
  • ::part(panel)
  • ::part(root)
  • ::part(search)
  • ::part(search-wrapper)
  • ::part(trigger)

ComboboxItem

Selector: mui-combobox-item

NameTypeDefaultDescription
valuerequiredstring— Value this option represents. Written to the combobox's `value` model when chosen.
disabledbooleanfalse Disables this option. It cannot be chosen. Accepts attribute presence, e.g. <… disabled>.

CSS parts

  • ::part(item)
  • ::part(item-root)

Tokens

  • --mui-color-surface-raised
  • --mui-color-border
  • --mui-shadow-3
  • --mui-color-primary-subtle
  • --mui-color-focus-ring
  • --mui-touch-target