Command
UI SDK Command list with search, groups, empty state and Kbd shortcuts, plus a CommandDialog palette with an opt-in mod+K trigger.
Example
Installation
lucide-reactUsage
Run actions through Command onAction. A command with href is a link instead: Enter, a click, its shortcut or a mouse press follow it (fast links: a #/… hash route or a same-origin path on press), and it never runs onAction. Pass onFollow to route on the client and close the palette.
API reference
Command
Takes every prop of UI SDK Command.
CommandInput
CommandList
CommandEmpty
CommandStatus
CommandGroup
CommandGroupLabel
CommandItem
| Prop | Type | Default |
|---|---|---|
hrefRenders the command as a link that navigates instead of running `onAction`: Enter, a click, its shortcut or a mouse press (see `fast`) follow it. Modified clicks keep the browser's behaviour, like opening a new tab. | string | – |
onFollowTakes over following, for client-side routing or to close the palette first. Receives the authored `href`. | (href: string, details: CommandItemFollowDetails) => void | – |
fastFollows a same-origin link on mouse press, not release (default `true`): navigation only, as moving away can't cancel it (WCAG 2.5.2). Off with a `target` or `download`; `data-no-fast-link` on an ancestor turns a region off. | boolean | true |
target | string | – |
rel | string | – |
download | boolean | string | – |
Also takes every prop of UI SDK CommandItem.
CommandRows
| Prop | Type | Default |
|---|---|---|
itemsrequiredThe commands to show: `CommandList`'s `state.items`, with `items` passed to `Command`. | CommandData | – |
childrenWhat a command shows. Its label by default. | (item: Item) => ReactNode | – |
virtualize`"auto"` renders only the commands in view past 50; `true` always, `false` never. | Virtualize | "auto" |
estimateItemSizeA command's height in px before it's measured, for rows taller than `h-control-sm`. Keep it stable. | (item: Item) => number | undefined | – |
CommandItemIcon
CommandSeparator
CommandFooter
Takes <div> attributes.
CommandShortcut
CommandDialog
| Prop | Type | Default |
|---|---|---|
escapeKeyWhat Escape does while focus is in the search field. `close` closes the dialog whatever the field holds, and focus returns to the trigger. `clear` keeps UI SDK's Command order: the first Escape clears the search, the next goes back a page, and only an empty first page lets Escape close the dialog. | "close" | "clear" | "close" |
Also takes Dialog.
CommandDialogTrigger
Takes DialogTrigger.
CommandDialogOpenButton
| Prop | Type | Default |
|---|---|---|
controllerrequiredThe CommandDialog's controller, from `createCommandDialogController()`. | { open: () => unknown } | – |
Also takes Button.
CommandDialogShortcut
CommandDialogContent
| Prop | Type | Default |
|---|---|---|
title | ReactNode | "Command palette" |
Also takes DialogContent.
Other exports
CommandHostContextCommandItemTextCommandPageCOMMAND_VIRTUALIZE_THRESHOLDcreateCommandControlleruseHighlightFirstOnOpencreateCommandDialogControllercreateCommandHighlightuseCommandRowstype CommandDatatype CommandDataItemtype CommandHosttype CommandItemFollowDetailstype CommandItemPropstype CommandPropstype CommandDialogContentPropstype CommandDialogControllertype CommandDialogOpenButtonPropstype CommandDialogPropstype CommandHighlighttype CommandRowtype CommandRowPropsAccessibility
- Typing filters; arrow keys move the highlight; Enter runs, or follows a link command.
- A link command stays an option of the listbox, rendered as an anchor, so modified clicks open a new tab.
- The ⌘K shortcut is opt-in on the trigger.
- In a CommandDialog, each open starts with an empty search, and one Escape closes it and returns focus to the trigger; escapeKey="clear" clears the search first.
Agent actions
Agents search and highlight commands by name (setQuery, setValue); UI SDK offers no action that runs one.
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.