Skip to content
Twentyfirst UIHalo

Search Trigger

Navigation · SearchTrigger, CommandPalette

View as Markdown

A search field that opens your search instead of taking text: the topStart of the standard top bar, opening a CommandPalette. It looks like SearchField and says it opens a dialog.

  • shortcut="⌘K" shows the key hint (hidden on touch screens); bindShortcut opens it with ⌘/Ctrl + the hint's last key, except while the reader types in a field.
  • On phones the top bar shows topStartCompact instead: pass an IconButton that opens the same search.
tsx
<AppShell navigation="sidebar" topbar
  topStart={<SearchTrigger placeholder="Search…" shortcut="⌘K" bindShortcut onClick={() => setOpen(true)} />}
  topStartCompact={<IconButton icon="search" label="Search" variant="ghost" onClick={() => setOpen(true)} />}
  …
/>
<CommandPalette open={open} onClose={() => setOpen(false)} items={pages} />

Click it or press ⌘K.

Props

SearchTrigger

PropTypeNotes
placeholder?stringThe text in the field (default "Search").
label?stringAccessible name instead of the visible text (keep the visible text in it).
shortcut?stringThe key hint, e.g. "⌘K" (hidden on touch screens).
bindShortcut?boolean⌘/Ctrl + the hint's last key opens it too, except while typing in a field.
onClick?() => voidOpens your search, e.g. a `CommandPalette`.
className?stringExtra class on the root element.
style?CSSPropertiesInline style on the root element.

CommandPalette

PropTypeNotes
itemsPaletteItem[]Required
onClose?() => void
placeholder?string
inline?boolean
loading?booleanResults are on their way (async search): shows a loading row.
empty?ReactNodeShown when nothing matches (default: "Nothing matches …").
onQueryChange?(query: string) => voidCalled with the query as the user types, for searching on a server.
open?booleanOptional: with `open` the component stays mounted while it animates out; without it, render it only while open.
className?stringExtra class on the root element.
style?CSSPropertiesInline style on the root element.