Command: Dialog
Put a <Command /> inside <CommandDialog /> and toggle it with useCommandHotkey. Press ⌘K or Ctrl K. Item shortcuts run while it is open, matches are highlighted, and preserveSearch keeps the query and selection for the next time it opens.
Nothing run yet. Theme: System.
This adds the example as components/examples/command/dialog.tsx, together with the Command component and the HextaUI theme tokens it needs.
pnpm dlx shadcn@latest add https://hextaui.com/r/command-dialog.jsonTo add only the component, follow the Command installation.
Props in this example
The Command props this example sets, from the API reference.
| Prop | Type | Default |
|---|---|---|
highlightHighlights the matched letters in each item and dims the rest. | boolean | false |
| Prop | Type | Default |
|---|---|---|
open | boolean | – |
onOpenChange | (open: boolean, details) => void | – |
preserveSearchKeep the dialog mounted so the query, page and selection survive closing. The query is selected when it reopens. | boolean | false |
| Prop | Type | Default |
|---|---|---|
placeholder | string | – |
| Prop | Type | Default |
|---|---|---|
heading | ReactNode | – |
| Prop | Type | Default |
|---|---|---|
onSelectRuns on click, Enter or the item’s shortcut, after the confirm blink. | (value: string) => void | – |
keywordsExtra words that match this item. | string[] | – |
disabled | boolean | false |
shortcutA hotkey like "mod+shift+c". Shown on the item and runs it while focus is in the menu. | string | – |
pageOpens the CommandPage with this id instead of running. | string | – |
pageTitleTitle shown in the page chip. Defaults to the value. | string | – |
hrefRenders the item as a link. Enter follows it, ⌘ or Ctrl Enter opens a new tab. | string | – |
| Prop | Type | Default |
|---|---|---|
idMatches the page prop of the item that opens it. Its groups and items only render while it is the current page. | string | – |
| Prop | Type | Default |
|---|---|---|
hotkeyFormats a hotkey like "mod+k" for the current platform. Children override it. | string | – |
Every prop is in the Command API reference.
See them all, with keyboard support and accessibility notes, on the Command page.
- ButtonButtons in every variant and size, with a built-in loading, success and error flow that skips the spinner for fast requests.
- HotkeyParse, label, announce and match keyboard shortcuts, with ⌘ on Apple platforms and Ctrl everywhere else.
- MotionThe easing curves, durations and reduced-motion check every component animates with, plus hooks for size morphs and sliding highlights.
- SpinnerA loading indicator with Apple-style ticks or a breathing ring that can wait before showing and stay long enough not to flicker.
- Alert dialogA confirmation dialog for destructive or important actions that waits for async work, and becomes a bottom sheet on phones.
- Context menuA menu of actions on right click or long press, with submenus, checkbox and radio items, and hold feedback on touch.