Overlays
Command
A keyboard-first command palette with filtering, groups, and shortcuts.
Keyboard first: ↑ ↓ to move, Enter to run, Esc to close.
Installation
Copy the source with the CLI to own and edit it, or import it from the npm package.
npx aback-ui@latest add commandWrites components/ui/command.tsx and the components it builds on. First time in this project? Run npx aback-ui@latest init first, as the installation guide shows.
Usage
Import the parts you need from the installed file. The Code tab above has a complete, working example.
import {
Command,
CommandDialog,
CommandInput,
CommandList,
CommandEmpty,
CommandGroup,
CommandItem,
CommandSeparator,
CommandShortcut,
} from "@/components/ui/command";API reference
Props and composition points for Command. Native element props pass through.
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | None | Accessible name for the search input. Required; cmdk renders a visually hidden label from it. |
shouldFilter | boolean | true | Filters items by the query. Turn it off when results come from a server and you filter them yourself. |
CommandDialog open / onOpenChange | boolean / (open: boolean) => void | None | Renders the palette in a modal Dialog. The dialog title and description are visually hidden but announced. |
CommandItem value / onSelect | string / (value: string) => void | None | The value used for filtering and the callback that runs on click or Enter. |
CommandShortcut | component | None | A right-aligned keyboard hint. It is decorative text; the action must remain understandable without it. |
Dependencies: @tabler/icons-react, cmdk, plus the shared @/lib/utils helper.
Accessibility
Semantics, keyboard behavior, and the decisions that keep the component operable.
- The
labelprop is not decoration: it names the combobox input. Without it the input is announced as an unnamed edit field. - CommandDialog renders a real Dialog with an accessible title and description, focus trapping, Escape, and focus return.
- cmdk manages the combobox, listbox, and option roles, aria-activedescendant, and the selected state.
- Filtering keeps the list in sync with aria-activedescendant. Keep items short and do not put a second interactive control inside an item.
Keyboard
| Key | Action |
|---|---|
| ArrowUporArrowDown | Move the active option. |
| Enter | Run the active option. |
| Escape | Close the dialog and return focus to the trigger. |
Open the palette with an explicit trigger or a global shortcut. If you advertise ⌘K, implement it and show Ctrl K on non-Apple platforms.
Used in production
The Aback products whose interfaces shaped this component.