Skip to content
Eskais UI

Overlays

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

npx shadcn@latest add @eskais/command
npm packageslucide-react

Usage

Import
import {  Command,  CommandEmpty,  CommandFooter,  CommandGroup,  CommandGroupLabel,  CommandHostContext,  CommandInput,  CommandItem,  CommandItemIcon,  CommandItemText,  CommandList,  CommandPage,  CommandRows,  CommandSeparator,  CommandShortcut,  CommandStatus,  COMMAND_VIRTUALIZE_THRESHOLD,  createCommandController,} from "@/components/ui/command"import { useHighlightFirstOnOpen } from "@/components/ui/use-command-reset"import {  CommandDialog,  CommandDialogContent,  CommandDialogOpenButton,  CommandDialogShortcut,  CommandDialogTrigger,  createCommandDialogController,} from "@/components/ui/command-dialog"import { COMMAND_VIRTUALIZE_THRESHOLD, createCommandHighlight, useCommandRows } from "@/components/ui/use-command-rows"

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

CommandItem

PropTypeDefault
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.booleantrue
targetstring–
relstring–
downloadboolean | string–

Also takes every prop of UI SDK CommandItem.

CommandRows

PropTypeDefault
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–

CommandFooter

Takes <div> attributes.

CommandDialog

PropTypeDefault
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

PropTypeDefault
controllerrequiredThe CommandDialog's controller, from `createCommandDialogController()`.{ open: () => unknown }–

Also takes Button.

CommandDialogShortcut

Takes every prop of UI SDK DialogShortcut.

CommandDialogContent

PropTypeDefault
titleReactNode"Command palette"

Also takes DialogContent.

Other exports

CommandHostContextCommandItemTextCommandPageCOMMAND_VIRTUALIZE_THRESHOLDcreateCommandControlleruseHighlightFirstOnOpencreateCommandDialogControllercreateCommandHighlightuseCommandRowstype CommandDatatype CommandDataItemtype CommandHosttype CommandItemFollowDetailstype CommandItemPropstype CommandPropstype CommandDialogContentPropstype CommandDialogControllertype CommandDialogOpenButtonPropstype CommandDialogPropstype CommandHighlighttype CommandRowtype CommandRowProps

Accessibility

  • 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.