shadcn.io is not affiliated with official shadcn/ui
Command examples · Dialog
Command Dialog Actions Menu for React
A Quick Actions button that opens a command dialog of file actions, each with an icon and a shortcut hint.
Six file actions in two groups, Quick Actions and File Actions, each with an icon and the shortcut it stands for. Use it where the same few operations come up again and again and people would rather type than hunt through a toolbar. The Quick Actions button opens the menu in a CommandDialog over the page, and Escape closes it. In React, Base UI handles the keyboard navigation.
Preview
Installation
FAQ
How does this dialog open?
The Quick Actions button sets an open state to true, and CommandDialog takes that state with its change handler, so Escape or a click outside sets it back. The dialog has a visually hidden title and description.
The Command goes straight inside CommandDialog.
How are the actions grouped?
Two CommandGroups: Quick Actions holds Open, Copy and Add to Favorites, and File Actions holds Download, Share and Delete. There is no separator, so the headings alone split them. Each row starts with a decorative icon: ArrowRight, Copy, Star, Download, Share or Trash.
Where do the key hints come from?
Each hint is a CommandShortcut: Open shows ↵, Copy ⌘C, Add to Favorites ⌘D, Download ⌘⇧D, Share ⌘⇧S and Delete ⌘⌫. It's a label at the end of the row and binds nothing: listen for those keys yourself if they should run the action.
What appears when nothing matches the search?
CommandEmpty in the list says "No actions found." It shows only when the search leaves nothing.
How do I run an item from this dialog in React?
These items don't run anything yet.
Pass onSelect to each CommandItem. Close the dialog in the same handler.
How do the keys work in this dialog?
The arrow keys move through the items, Enter runs the highlighted one, and typing filters the list. Escape closes CommandDialog, and focus goes back to the button. CommandInput shows "Search actions..." until someone types.
Command filters and ranks the items by their text on its own.
Related
- Command Actions MenuAn inline command menu of quick and file
- Command Popover Actions MenuA Quick Actions button that opens a
- Command with Icons and ShortcutsAn inline command menu with icons on
- Command Dialog with BadgesA Browse Components button that opens a
- Simple Context MenuA right-click area that opens Back
- Command Dialog with DescriptionsA Search Contacts button that opens a