Browse the docs
Inputs / SearchField & CommandPalette

SearchField & CommandPalette

A search box with a wobbly marker outline that boils while it has focus, grouped results on a taped sheet, highlighter matches and keycap shortcuts. The same field powers a ⌘K command palette.

Client componentWCAG AANew

Change every prop live in the playground.

Props

SearchField

PropTypeDefaultWhat it does
label requiredstring—What you're searching, e.g. "Search components". Always read by screen readers.
classNamestringnone—
defaultValuestringnone—
emptyGroupsSearchGroup[]noneShown when the box is empty and focused, e.g. quick actions. Recent searches come first.
filterbooleanfalse—
focusOnMountbooleanfalse—
groupsSearchGroup[]noneWhat can be found. Filtered as you type (title, sub, meta and keywords); pass `filter={false}` if you filter yourself, e.g. on a server.
hideLabelbooleanfalseHide the label visually (it stays for screen readers). Use it in tight headers.
inlinebooleanfalse—
limitnumber4Max results per group.
loadingbooleanfalseHop dots instead of the eraser while results load.
onSelect(item: SearchItem, group: SearchGroup) => voidnonePicked with Enter or a click.
onValueChange(value: string) => voidnone—
placeholderstringnone—
recentKeystringnoneRemember picks under this localStorage key and offer them as recent searches.
shortcutstringnoneA keycap hint, and the key that focuses the field from anywhere on the page. `"/"` is a good one.
size"sm" | "md" | "lg"none`sm` for headers, `md` (default), `lg` for a page about finding things.
valuestringnone—

CommandPalette

PropTypeDefaultWhat it does
groups requiredSearchGroup[]—What can be found while typing.
onSelect required(item: SearchItem, group: SearchGroup) => void——
emptyGroupsSearchGroup[]noneShown before typing, e.g. quick actions.
labelstringnone—
onOpenChange(open: boolean) => voidnone—
openbooleanfalseControlled open state. Leave both out and the palette opens with the shortcut on its own.
placeholderstringnone—
recentKeystringnone—
shortcutbooleantrueToggle with Cmd+K on a Mac, Ctrl+K elsewhere.

Use it well

DoGroup results by kind and give each a lead (a face, a status dot, an icon) so people can scan without reading.
Don'tHide the only way to reach a page inside the palette. It's a shortcut, not the map.

Accessibility

  • The input is a combobox: aria-expanded, aria-controls and aria-activedescendant follow the arrow keys.
  • Enter opens the active (or first) result; Escape clears the text, then closes.
  • The result count is announced in a polite live region; group headings are never focusable.
  • The palette is a native <dialog>, so focus stays inside and Escape closes it.
Five stamps!

All aboard.

You took the whole tour. Here's Holo Pip, a foil sticker for riders who finish. It's in your playground tray now, for good.