shadcn.io is not affiliated with official shadcn/ui
Navigation Command Menu Block for React
A bank back office's navigation menu shown open: 24 pages in three levels, each row the name over its whole path, a search that reads the path by the start of each word, and a tick on the page you are on.
Installation
Overview
Get around a big console without the sidebar with this navigation command menu for React with Base UI. It opens from the admin console of Tillerbank, a retail bank's back office, whose header holds an outline field with its ⌘ K cap, and the console is drawn under a soft scrim inside a hairline frame with a plus mark on each corner: a sidebar of six sections, a breadcrumb and a table. The menu is the catalog Command over 24 pages in three levels, grouped by section, each row an icon, the page's name and its whole path under it in muted text. The search reads the path too, by the start of each word, so "bill inv" finds Settings, Billing, Invoices, and the words you typed are marked in the name and the path. The page you are on carries a tick and the words "You are here". Choosing a page moves the drawn console's breadcrumb and its sidebar's tinted section, and the status line says where you went; nothing loads. The foot lists the keys and counts the pages, which is also spoken. For preview the menu is drawn open in place when the page loads; the field, or Ctrl or ⌘ K while focus is in the block, opens the real command dialog with the same rows and query. For admin consoles, dashboards and docs with many nested pages.
FAQ
Why is the menu already open, and what do I keep?
So you can see it without a click. On load the menu is the Command drawn inline over a picture of the console, in a plain shell that is not modal, so nothing is trapped, hidden or focused and the page around the preview keeps working. The header's field opens the real command dialog, modal, with its focus trap, Escape and focus return, and the inline copy stays closed until a reload. Both show the same Palette component and share the block's state. In your app keep the dialog and drop the copy: the "in-place" state, the scrim with its shell and the Escape and blur effects.
How does the path search match?
Each word you type must start some word of the page's path or of its hidden keywords, so the order does not matter and "inv bill" works as well as "bill inv". wordsOf splits on anything that is not a letter or a digit and ignores case and accents. The words are marked wherever they occur in the name and the path. A section with no match disappears, and with nothing left the empty state tells you to try the start of words from the path.
How is the current page shown?
Its row stays in the list with a tick and the words "You are here", so the list never changes length. Choosing another page moves both: the breadcrumb in the drawn page header shows its path, the sidebar tints its section, and the status line says "Went to Settings › Billing › Invoices. In this demo only." In your app set current from your router.
How do I wire it to my pages?
Replace PAGES with your route table: each page("Section/Group/Name", "keywords") is one row, and the trail becomes the title, the path and the section. In pick call your router instead of setting local state, for example router.push(found.href) with an href added to Page.
Is it accessible from the keyboard?
Yes. Type to search, the arrow keys move through the rows, Enter goes to the highlighted page and Escape closes the menu and puts focus on the field; Ctrl or ⌘ K opens the dialog while focus is inside the block, and only then. The rows are options of a cmdk listbox; the block turns off its own fuzzy filter and lists the rows itself. The count is spoken a moment after typing stops.
Related
- Pro
Basic Command Menu
Search everythingA team workspace's home page with its command menu shown open: eleven pages in three groups, a shortcut on the five most used, matches marked, an empty state that says what to try and a foot with the key hints and a spoken count.
- 333Pro
Global Search Command Menu
Search everythingA company intranet's command menu shown open: one input searches pages, docs, people and tags at once, each type is a group of three matches with a row that opens it in place, and the foot counts the results by type.
- Pro
Page Stack Breadcrumb Command Menu
Pages and docsA CMS page browser as a command menu shown open as a page stack: a trail of crumbs over the list, the arrow keys go into a folder and back out, and a page closes the menu and names itself on the page list behind.
- Pro
Docs Tree Command Menu
Pages and docsAn API docs host's page finder as a command menu shown open on a tree: sections open into indented pages with the arrow keys, typing flattens the tree and matches the headings inside pages, and the foot counts the open sections.
- Pro
Command Palette Navbar
SearchA navbar for a notes app with a field-looking button and a shortcut that open a command palette: recent notes first, then pages, actions and settings in labelled groups, with the keys that work shown beside each row.
- Pro
Release Notes Command Menu
Pages and docsA release-notes tool's changelog as a command menu shown open under a What's new bell: a select says which version you are on, the list shows what came after it with fixed dates, chips filter by New, Improved or Fixed, and the count line says how many changes break something.