Command
Fast, composable, unstyled command menu.
Command is a command palette (fuzzy search and keyboard navigation). It is the ⌘K pattern popularized by Linear and Raycast: the user types, the list filters in real time, and Enter activates the focused item.
It can be used standalone (in a side panel) or embedded in a Dialog for a ⌘K modal.
Installation
$ bext ui add command
Copy and paste the following into src/components/ui/command.tsx.
This component is interactive. Make sure the shared island is loaded (see Islands). It reacts to data-ui="command" hooks.
Usage
Anatomy
<Command>
├── <CommandInput placeholder="Type a command..." />
└── <CommandList>
├── <CommandGroup heading="Suggestions">
│ ├── <CommandItem>Calendar</CommandItem>
│ └── <CommandItem>Search Emoji</CommandItem>
├── <CommandSeparator />
└── <CommandGroup heading="Settings">
└── <CommandItem>Profile</CommandItem>API Reference
Command
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Wrapper flex flex-col overflow-hidden rounded-md border bg-popover. |
CommandInput
| Prop | Type | Default | Description |
|---|---|---|---|
| placeholder | string | — | Placeholder of the search field. |
| className | string | — | Input with a built-in search icon on the left. |
CommandList
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Scrollable container for the items. max-h-[300px]. |
CommandGroup
| Prop | Type | Default | Description |
|---|---|---|---|
| heading | string | — | Muted section title above the items. |
CommandItem
| Prop | Type | Default | Description |
|---|---|---|---|
| href | string | — | If set, renders <a>, otherwise <div>. |
| onSelect | function | — | Callback on activation (Enter or click). |
CommandSeparator
| Prop | Type | Default | Description |
|---|---|---|---|
| — | — | — | Thin line between groups. |
CommandEmpty
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | Shown when no item matches. |
Data Attributes
Attributes you can target in custom CSS to override the style for each state.
| Attribute | On | Values | Description |
|---|---|---|---|
| data-command | root | — | Anchor for the fuzzy-search island. |
| data-command-item | CommandItem | — | Each item is matched against its text. |
Keyboard
| Key | Action |
|---|---|
| ↑ / ↓ | Moves between visible items. |
| Enter | Activates the focused item. |
| Escape | Closes (when inside a Dialog). |
| ⌘K / Ctrl+K | Convention for toggling a global command palette. |
Accessibility
CommandInput must have role="combobox", aria-expanded, aria-autocomplete="list". The list carries role="listbox", each item role="option" aria-selected.
Without these attributes, screen readers do not announce the live filtering.
Edit this component live in the bext playground. The PRISM + signals version is the bext-native idiom: fine-grained reactivity, no virtual DOM.
On This Page