Skip to content
satin

Search bar

A search field for the sidebar or a toolbar, with ⌘K to focus it from anywhere.

Installation

Terminal
npm i @uisatin/ui
Import
import { SearchBar } from '@uisatin/ui/search-bar'

About 15.6 kB of JavaScript, minified and gzipped, with what it imports (React aside). The stylesheet is one file for every component.

First time with Satin? Set it up once, styles and fonts included, with the installation guide.

API Reference

The SearchBar component is a wrapper around the input element of type search, with a search icon and the ⌘K keys. ⌘K or Ctrl+K anywhere on the page focuses it and Escape clears it. variant="panel" shows the results in place: groups filtered as you type, the arrows to move, Enter to open, a footer of key hints and meta.

PropTypeDefault
variant
"field""panel"
"field"
shortcut
boolean
variant === "field"
hotkey
boolean
shortcut
placeholder
string
"Search…"
groups
CommandGroup[]
—
idleText
ReactNode
—
emptyText
(query: string) => ReactNode
—
meta
ReactNode
—
hints
boolean
true
wrapperClassName
string
—
className
string
—
ref
Ref<HTMLInputElement>
—
...props
ComponentProps<'input'>

Other attributes go to <input>

—

Accessibility

A native input of type search (searchbox) named "Search" (searchField in SatinLabels) unless you pass aria-label ("Search docs"); the icon and keycaps are hidden. In the panel the input is a combobox that controls the results listbox; the highlighted row is its aria-activedescendant, so focus stays in the field.

KeyAction
⌘KorCtrl+KFocuses the field and selects its text, from anywhere on the page, unless hotkey is off.
↑or↓Panel: moves the highlight through the results, wrapping at the ends.
EnterPanel: opens the highlighted result (its onSelect).
EscClears the field when it has text.