CommandPalette
A ⌘K command menu with search, groups and keyboard navigation.
Animatedimport { CommandPalette } from 'umbra-ui/motion'
Props
| Prop | Type | Default | Description |
|---|---|---|---|
items required | CommandItem[] | — | Commands to search. |
closeOnSelect | boolean | true | Close after an item is chosen. |
defaultOpen | boolean | false | Initial open state when uncontrolled. |
emptyMessage | ReactNode | No results. | Shown when nothing matches. |
hotkey | boolean | true | Toggle with ⌘K / Ctrl+K from anywhere on the page. |
label | string | Command palette | Accessible name of the dialog and the result list. |
onOpenChange | ((open: boolean) => void) | — | Called when the palette opens or closes. |
onSelect | ((item: CommandItem) => void) | — | Called with the chosen item, after its own `onSelect`. |
open | boolean | — | Controlled open state. |
placeholder | string | Type a command or search… | Search field placeholder. |
reducedMotion | "system" | "always" | "never" | "system" | Reduced-motion override. Under reduced motion the palette fades without scaling. |
Usage notes
Filtering is a case-insensitive match of every search term against label, group and keywords.
Accessibility
- A modal dialog: focus is trapped, and restored to the previously focused element on close.
- The search field is a
comboboxcontrolling alistbox; the active option is tracked witharia-activedescendant. - ↑/↓ move (wrapping, skipping disabled), Home/End jump, Enter runs, Escape closes, ⌘K / Ctrl+K toggles.
- The number of results is announced politely.
Import
import { CommandPalette } from 'umbra-ui/motion';
import 'umbra-ui/styles.css'; // once, at the root of your app