On this page
<Card className="w-[300px] p-0">
<Command aria-label="Command menu">
<SearchField aria-label="Search">
<InputGroup>
<InputGroupAddon>
<SearchIcon />
</InputGroupAddon>
<Input />
</InputGroup>
</SearchField>
<ListBox aria-label="Suggestions" onAction={() => console.log("action")}>
<ListBoxSection>
<ListBoxSectionHeader>Suggestions</ListBoxSectionHeader>
<ListBoxItem textValue="Calendar">
<CalendarIcon />
<span>Calendar</span>
</ListBoxItem>
<ListBoxItem textValue="Search Emoji">
<SmileIcon />
<span>Search Emoji</span>
</ListBoxItem>
<ListBoxItem textValue="Calculator">
<CalculatorIcon />
<span>Calculator</span>
</ListBoxItem>
</ListBoxSection>
</ListBox>
</Command>
</Card>Installation
npx shadcn@latest add @dotui/commandUsage
Command is a thin wrapper around React Aria's Autocomplete. It ships no input or list of its own — you compose it from primitives you already have: a SearchField for the query and a ListBox for the commands. As the user types, the list is filtered down to the items whose text matches the query.
import { SearchIcon } from 'lucide-react'
import { Command } from '@/components/ui/command'
import { Input, InputGroup, InputGroupAddon } from '@/components/ui/input'
import { ListBox, ListBoxItem } from '@/components/ui/list-box'
import { SearchField } from '@/components/ui/search-field'<Command aria-label="Command menu">
<SearchField aria-label="Search">
<InputGroup>
<InputGroupAddon>
<SearchIcon />
</InputGroupAddon>
<Input placeholder="Type a command or search..." />
</InputGroup>
</SearchField>
<ListBox aria-label="Commands" onAction={(key) => console.log(key)}>
<ListBoxItem textValue="Calendar">Calendar</ListBoxItem>
<ListBoxItem textValue="Search Emoji">Search Emoji</ListBoxItem>
<ListBoxItem textValue="Calculator">Calculator</ListBoxItem>
</ListBox>
</Command>Filtering matches against each item's textValue. String children set it automatically, but items with rich content — an icon, a keyboard shortcut — need an explicit textValue to stay searchable. Group related commands with ListBoxSection and ListBoxSectionHeader, and respond to a selection with the list's onAction callback.
Because the input and the list are ordinary primitives, anything they support works here too: put the Command inside a Modal for a ⌘K palette, inside a Popover to filter a Select, or swap the ListBox for a TagGroup. See the examples below.
Examples
Basic
In a modal
In a select
With a tag group
API Reference
Command renders only the autocomplete wrapper. The input is a SearchField and the list is a ListBox — CommandInput and CommandContent are re-exported aliases for those primitives, so refer to their pages for the full set of props.
Command
A command palette combines a search input with a list of commands, allowing a user to filter and run them.
Supports all div attributes.
| Prop | Type | Default | |
|---|---|---|---|
CollatorOptions | — | ||
CommandInput
The search input used to filter the commands. Renders a `SearchField`.
| Prop | Type | Default | |
|---|---|---|---|
boolean | — | ||
boolean | — | ||
string | — | ||
ReactNode | function | — | ||
union | — | ||
union | — | ||
string | — | ||
union | 'search' | ||
string | — | ||
string | — | ||
function | — | ||
CommandContent
The list of commands, filtered to match the input's value. Renders a `ListBox`.
| Prop | Type | Default | |
|---|---|---|---|
DragAndDropHooks<NoInfer<T>> | — | ||
"grid" | "stack" | 'stack' | ||
Orientation | 'vertical' | ||
ReactNode | function | — | ||
Iterable<T> | — | ||
function | — | ||
readonly any[] | — | ||
SelectionMode | — | ||
SelectionBehavior | 'toggle' | ||
Iterable<Key> | "all" | — | ||
Iterable<Key> | "all" | — | ||
function | — | ||
Iterable<Key> | — | ||
boolean | — | ||
boolean | — | ||
boolean | — | ||
boolean | — | ||
"clearSelection" | "none" | 'clearSelection' | ||
Last updated on 6/27/2026