Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Command Palette Navbar Block for React

A 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.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A command-palette navbar for React with Base UI, the bar an app keeps above its pages. For Notehelm, a project notes app, the wordmark leads, four page links follow, and a button that looks like a search field, with its shortcut at the end, sits beside a Shine Button. The button, or Command and K from anywhere on the page (Control and K elsewhere), opens a command palette over the page: three recent notes first, then pages, actions and settings in labelled groups, narrowed as you type by label or group. Rows that have a key of their own (N for a new note, I to invite teammates, a comma for account settings) show it at the end and the key really does it from the page. Choosing a page moves the bar's current-page stroke, choosing a note moves it to the top of Recent, and a hidden status line says what was opened. The palette is a dialog, so the bar stays one bar high (64 pixels, 56 on a phone). On a phone the button is an icon and a menu button opens a sheet from the top with the same links. It's built from Command, Kbd, Sheet, Button, Shine Button and Guides with Lucide icons and your theme's tokens for every colour. It is not a call to action built around one shortcut, nor a line of text that hints at a command. For apps and products whose bar should reach any page or action in two keystrokes.

FAQ

How do I change the rows and make a choice do something?

Edit NOTES and OTHERS at the top of the file: each row has a group, an icon, a label, a value and, optionally, a key. choose(value) is the one place a row does its work: pages set the current page, notes move to the top of recent, and every choice updates the hidden status line. Replace its body with your router (router.push) and your actions. The page links in the bar and the sheet call the same function, so the bar and the palette never disagree about the current page.

How does the Command or Control key cap work?

The caps render the Apple key first, so the server and the first client render match, and swap to Ctrl after mount when the browser's user agent isn't an Apple device. The shortcut itself accepts both Command and Control with K on every device, and the button declares both with aria-keyshortcuts. The caps are hidden below the sm breakpoint, where there is rarely a keyboard.

Do the keys beside the rows work?

Yes. A document listener runs a row's key when no modifier is held, the palette is closed and the keyboard isn't in an input, a textarea, a select or an editable element, so typing "i" in the palette's own field only searches. Command or Control with K opens the palette from anywhere, including a text field.

How does it work with a keyboard and a screen reader?

The button says whether the palette is open (aria-expanded) and which element it controls (aria-controls). The palette is a modal dialog named Command palette: focus moves to its field, the arrow keys move through the rows, Enter chooses one and Escape closes it, and focus returns to the button that opened it (or to the visible one when the shortcut did). The rows are options of a listbox that filters by substring over each row's label and group; the block returns focus to the button one tick after the dialog closes.

How does it work on a phone?

Below the md breakpoint the field-looking button becomes an icon button that opens the same palette, and below lg a menu button opens a sheet from the top whose header lines up with the bar, with the four links and Get Notehelm (the bar's own button hides below sm). Choosing a link closes the sheet and Escape returns focus to the menu button. Nothing wraps at 320 pixels, and the palette fits the screen.

  • Pro

    A navbar for a legal-research database whose field-looking search button opens a panel from the top with a large input, recent searches you can remove, popular topic tags and live results with the matching letters marked.

  • Pro

    An app navbar whose shortcuts work: G then H, P or S moves between pages, a question mark opens a dialog with every key in a table, and each link shows its keys on hover and keyboard focus.

  • Pro

    A navbar for a support-desk product with a search field whose popup lists help articles and categories in two labelled groups, marks the matching letters, and offers an Ask support link when nothing matches.

  • Pro

    A one-bar marketing navbar for a product roadmap tool: a wordmark, a Product menu of four areas with icons and one-line descriptions, plain links with the current page marked, Sign in and a Shine Button, and a sheet with the same links on phones.

  • Pro

    A one-line shortcut hint for a docs app: key caps drawn inline that read Command K on a Mac and Ctrl K everywhere else, and an underlined link to all shortcuts.

  • Pro

    A FAQ for a docs host with a working command palette: a search-field button with its shortcut opens a palette of questions by topic, and choosing one opens its row below.