Command

Demo

Press K

Props

PropTypeDescription
inputboolean (optional)Determines if an input field is displayed.
inputPlaceholderstring (optional)Placeholder text for the input field.
emptyPlaceholderstring (optional)Placeholder text to display when there are no command items.
commandGroupsCommandGroup[] (optional)An array of command groups, each with items and a heading.
classNames{ [key: string]: string } (optional)Custom class names for various Command components.

CommandGroup Type

PropTypeDescription
headingstring (optional)The heading text for the command group.
isSeparatorboolean (optional)If true, renders a separator instead of command items.
itemsArray (optional)An array of command items within the group.

CommandItem Type within CommandGroup

PropTypeDescription
textstringThe text displayed for the command item.
iconReact.ReactNode (optional)An icon displayed next to the command item text.
hrefstring (optional)URL to navigate to when the command item is selected.
shortcutstring (optional)A keyboard shortcut associated with the command item.
disabledboolean (optional)If true, the command item is disabled.
onSelect(value: string) => void (optional)Function called when the command item is selected.

Styles

This component allows for custom styles via the classNames prop:

  • root: CSS class for styling the overall Command component.
  • input: CSS class for styling the input field.
  • empty: CSS class for styling the empty state display.
  • list: CSS class for styling the list of command groups.
  • group: CSS class for styling each command group.
  • item: CSS class for styling individual command items.
  • separator: CSS class for styling separators between groups.
  • shortcut: CSS class for styling keyboard shortcuts displayed on command items.