Skip to content
satin

Command menu

The ⌘K palette: search every action and page, then run one with Enter.

Installation

Terminal
npm i @uisatin/ui
Import
import { CommandMenu } from '@uisatin/ui/command-menu'

About 29.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 CommandMenu component wraps the Radix dialog in a div with a search input (role="combobox") and a listbox of grouped commands. ⌘K or Ctrl+K toggles it unless hotkey is off. For a menu that changes what it shows: query / onQueryChange control the search (emptied as the menu closes), an item with keepOpen runs without closing it, header goes above the search row, children take the list's place and footer replaces the key hints (compose it from KbdHint).

PropTypeDefault
groups
CommandGroup[]
—
item.label
string
—
item.icon
ReactNode
—
item.description
string
—
item.shortcut
string
—
item.onSelect
() => void
—
hotkey
boolean
true
hints
boolean
true
placeholder
string
—
open
boolean
—
defaultOpen
boolean
false
onOpenChange
(open: boolean) => void
—
emptyText
(query: string) => ReactNode
—
modal
boolean
true
item.keepOpen
boolean
false
query
string
—
onQueryChange
(query: string) => void
—
header
ReactNode
—
footer
ReactNode
—
children
ReactNode
—
className
string
—
ref
Ref<HTMLElement>
—
...props
ComponentProps<typeof Dialog.Content>

Other attributes go to the Radix Dialog.Content part

—

Accessibility

A Radix dialog titled "Command menu" for screen readers. The search input is a combobox named "Search commands" that points at the highlighted row with aria-activedescendant; the rows are options in a listbox named "Commands", grouped under their headings. The key hints in the footer are hidden.

KeyAction
⌘KorCtrl+KOpens or closes the menu from anywhere on the page, unless hotkey is off.
↑or↓Moves the highlight, wrapping at the ends.
EnterRuns the highlighted command and closes the menu.
TaborShift+TabKeep focus inside the menu while it is modal (the default).
EscCloses the menu and returns focus to where it was.