Powerful and customizable React command menu components built for modern applications and websites. These command menus are built using React Aria and styled with Tailwind CSS.
Installation
You can add this command menu component using our CLI or manually:
npx untitledui@latest add command-menu
Command menu examples
Below are examples and variations of this command menu component:
API reference
Import the parts and assemble them:
import { CommandMenu } from "@/components/application/command-menus/command-menu"; <CommandMenu> <CommandMenu.Group> <CommandMenu.List> <CommandMenu.Section /> </CommandMenu.List> <CommandMenu.Preview /> </CommandMenu.Group> </CommandMenu>
CommandDialog
Renders React Aria’s ModalOverlay — all of its props are supported.
Props from React Aria Components (13)
Also accepts the global HTML attributes (dir, lang, hidden, inert, translate), all standard React DOM event handlers.
FAQs
Please refer to our frequently asked questions page for more.
The shortcut prop registers a global hotkey that focuses the search input of an already-open menu — it does not open the menu. It defaults to "⌘/"; pass a different string to change it, or shortcut={null} to register nothing. To open the menu, drive the isOpen and onOpenChange props yourself, or wrap a button in CommandMenu.Trigger.
items (or defaultItems for an uncontrolled list) takes an array of groups shaped { id, title?, items }. Every entry in a group's items needs an id and a label (the label is also the text the search matches against), and can carry description, shortcutKeys and stacked. The search input's placeholder defaults to "Search" and is changed with the placeholder prop.
Set type on an item to "icon" (add an icon component), "avatar" (add src and alt), or "dot" (add dotColor: "green"); omitting type gives the plain "default" item. Adding stacked to any item switches it to a two-line layout with the description below the label and a larger leading icon or avatar.
Yes. Pass filter={false} to switch off the built-in filtering and feed already-filtered results into items yourself, driving the query with the inputValue and onInputChange props. By default the menu filters with React Aria's contains matcher, whose sensitivity prop defaults to "base", and you can also supply your own filter function.
Pass any React node to the emptyState prop on the command menu root. It is rendered by the underlying list box whenever the filtered result set is empty.
Give the item a shortcutKeys array, for example shortcutKeys: ["⌘", "K"]. The keys are rendered next to the item and registered as a hotkey that fires onSelectionChange with that item's id, so the command can be triggered without opening the menu.
Compose them from the sub-components: CommandMenu.List holds CommandMenu.Section and CommandMenu.Item, CommandMenu.Footer pins a footer to the bottom of the dialog, and CommandMenu.Preview takes a render prop receiving { selectedId } so you can show details for the currently selected command.