Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Actions Command Menu Block for React

A signing tool's document with its actions menu shown open: nine actions in four groups, a key on the five that change the document that runs them while the menu is open, and a drawn lease whose badge and signature follow.

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

Put a document's actions behind one menu with this actions command menu for React with Base UI. It opens from a lease agreement in Wetpen, a document-signing tool: the header holds an outline actions field with its ⌘ K cap, and the lease is drawn under a soft scrim inside a hairline frame with a plus mark on each corner, its toolbar carrying the button the menu hangs from. The menu is the catalog Command with nine actions in four groups, Document, Signing, Go to and Help, each with an icon and the letters you typed marked with Search Highlight Text, and a Kbd key on the five that change the document: Rename, Duplicate, Export PDF, Sign and Request signature. While the menu is open each key runs its action without moving the highlight: the row flashes once, the drawn document's Badge moves from Draft to Waiting on 1 signer or Signed by you, a signature appears in its box, and the status line says what ran and that nothing was signed or sent. Enter or a click runs the highlighted action and closes the menu. For preview the menu is drawn open in place when the page loads; the actions field, or Ctrl or ⌘ K while focus is in the block, opens the real command dialog with the same rows and query. For document tools, editors and admin pages where a few actions need a key.

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 lease, in a plain shell that is not modal, so nothing is trapped, hidden or focused and the page around the preview keeps working. The actions 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 do the keys work?

Alt and a letter, or Option on a Mac, runs the action while the menu is open and its input has focus: N rename, U duplicate, X export, G sign and Q request a signature. The block reads the physical key (event.code), so Option's special characters never matter, calls preventDefault so nothing is typed, and ignores the chord when Ctrl or Command is also down. The highlight does not move and the menu stays open, so you can run two actions in a row; Enter or a click runs the highlighted one and closes. The caps say Alt or Option to match the system. The letters avoid the ones browsers use for their menus.

What is the flash, and does it respect reduced motion?

A tint that fades out over half a second on the row whose key you pressed, so the key has a visible answer even when the status line is off screen. Under reduced motion it isn't drawn, and the badge, the signature and the status line still change. Each press mounts a new element, so the flash plays again.

What stays local, and how do I wire it up?

Everything. Sign sets a flag that the drawn badge and signature read, Request signature sets another, and the other actions only say what they would do: rename leaves the title, duplicate makes no copy, export downloads nothing. In your app replace the bodies in run with your calls, for example a request to your signing API for Sign, and set the badge from what the server returns.

Is it accessible from the keyboard?

Yes. Type to filter, the arrow keys move through the rows, Enter runs the highlighted action and Escape closes the menu and puts focus on the actions 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 real dialog is named by its title and described by its sentence.

How does it look on a phone?

The copy shown on load docks to the top of the page under the toolbar at full width, so the keyboard does not cover the foot; the key hints go, the count stays, and each row keeps its key cap (a phone with a hardware keyboard can use them). The real dialog keeps the Command dialog's own phone layout.

  • Pro

    Basic Command Menu

    Search everything

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

  • Pro

    A 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

    A task app's shortcut sheet as a command menu shown open as a help popover at the corner: a Mac or Windows switch re-labels every key cap, groups fold from their heads, search filters by action name, and a button really copies the list as a Markdown table.

  • Pro

    Recent Items Command Menu

    Search everything

    A project hub's command menu shown open on what you opened lately: Today, Yesterday and Earlier buckets before you type, recent matches first when you do, opening a row moves it to the top, and a last row clears the list.

  • Pro

    Command Palette Dialog

    Pickers and search

    A docs workspace's command palette shown open over its page: Recent and Pages when the field is empty, and a typed greater-than, at or hash turns it to Actions, People or Pages, each with its own groups and count, and each choice edits the drawn page.

  • Pro

    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.