Command Bar

A command menu interface for quick actions and navigation.

In a dialog

The usual command bar: a search field over grouped pages and actions. Give Dialog.Content an aria-label so the dialog has a name, and set inDialog on Command.Root for the larger input and item sizing.

Inline

Command.Root also works without a dialog, for example as a searchable picker inside a card. Pass label to name the list.


Command.Root Properties

inDialog
boolean

Uses the larger input, item, and group spacing for a command bar inside a Dialog

Default: false

label
string

Accessible label for the command menu. Not shown visibly.

value
string

Controlled value of the highlighted item

defaultValue
string

Highlighted item value on first render

onValueChange
(value: string) => void

Callback fired when the highlighted item changes

shouldFilter
boolean

Set to false to turn off built-in filtering and sorting, then render matching items yourself

Default: true

filter
(value: string, search: string, keywords?: string[]) => number

Custom match score from 0 (hidden) to 1 (best match)

loop
boolean

Wraps arrow-key navigation from the last item to the first

Default: false

className
string

Additional CSS classes to apply to the root

Command.Input Properties

value
string

Controlled search text

onValueChange
(search: string) => void

Callback fired when the search text changes

placeholder
string

Placeholder shown next to the search icon

Command.Item Properties

onSelect
(value: string) => void

Callback fired when the item is chosen by click or Enter

value
string

Unique value for the item. Inferred from the text content when omitted.

keywords
string[]

Extra terms to match when filtering

disabled
boolean

Whether the command item is disabled

Default: false

forceMount
boolean

Always renders the item, regardless of filtering

Default: false

Command.Group Properties

heading
ReactNode

Heading rendered above the group's items

value
string

Unique value for the group. Required when there is no heading.

forceMount
boolean

Always renders the group, regardless of filtering

Default: false

Other Parts

Command.List
ComponentPropsWithoutRef<typeof CommandPrimitive.List>

Scrollable container for groups, items, and separators. Caps at 300px tall.

Command.Empty
ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>

Displayed when no search results are found

Command.Separator
ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>

Line between groups. Hidden while searching unless alwaysRender is set.