Skip to main content

Command

Fast, composable, unstyled command menu for React.

import {
Command,
CommandInput,
CommandList,
CommandEmpty,
CommandGroup,
CommandItem,
} from "@/components/ui/command"

<Command className="rounded-lg border shadow-sm">
<CommandInput placeholder="Search categories" />
<CommandList>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup heading="Section Title">
<CommandItem className="flex items-center justify-between">
<span>Item</span>
<div className="flex flex-col items-end">
<span className="font-medium">$0.01</span>
<span className="text-xs text-green-600">24.9%</span>
</div>
</CommandItem>
</CommandGroup>
</CommandList>
</Command>

API Reference

PropTypeDefaultDescription
labelstringAccessible label for the command menu
shouldFilterbooleantrueWhether to automatically filter items based on search
filterfunctionCustom filter function (value, search) => number
valuestringControlled selected value
onValueChangefunctionCallback when the selected value changes

CommandInput

PropTypeDefaultDescription
placeholderstringPlaceholder text for the search input
valuestringControlled input value
onValueChangefunctionCallback when the input value changes

CommandGroup

PropTypeDefaultDescription
headingstringGroup heading displayed above the items
forceMountbooleanfalseForce render even when no results match

CommandItem

PropTypeDefaultDescription
valuestringUnique value for filtering and selection
onSelectfunctionCallback when the item is selected
disabledbooleanfalseWhether the item is disabled

Accessibility

The Command component follows WAI-ARIA combobox and listbox patterns:

  • Uses appropriate ARIA roles (combobox, listbox, option)
  • Supports keyboard navigation (Arrow keys to move between items, Enter to select)
  • Search input is properly labeled and announces results to screen readers
  • Groups use role="group" with accessible headings
  • Disabled items are properly communicated to assistive technology