Command menu
A React component in Beamline's Overlays category, in the free sample.
Search-first list of every action: ranked matching, groups, keycap shortcuts and nested pages; inline as CommandPalette or in a ⌘K dialog as CommandMenu.
Use it for
- App-wide ⌘K search and actions with groups, nested pages and shortcuts.
Not for
- Searching one list on a page (search-field).
- One object's actions (dropdown-menu).
Anatomy
- field (search icon or page chip)
- list: group headings, options (icon, label with match, description, shortcut — a combination ⌘N or a sequence G then A —, ›)
- empty state
- key hints
States
- empty query
- filtered
- no match
- loading (busy line under the field; rows shaped like results until any arrive)
- in a page
- option active
- option disabled
- narrow (under 24rem the shortcut keycaps fold away; labels and descriptions keep the row; under 20rem the footer keeps run and close, the arrows' hint gives way)
- touch (no key hints: the list takes their room)
- server-rendered (active-row selection does not read browser globals; keyboard and pointer selection start after hydration)
Keyboard
- An empty result is a status rather than an empty expanded listbox. Loading exposes a busy list; available results expose the controlled listbox and its active option.
- Type to filter
- ↑ ↓ move (wrapping), Home / End
- Enter runs or opens a page
- Backspace on an empty field goes back
- Escape goes back, then closes
- ⌘K / Ctrl K toggles the dialog
Motion
The highlight is one plate that glides between rows for the arrow keys and the pointer (--pui-duration-fast); it appears in place when the list's question changes. A nested page slides in from the side it comes from (forward from the inline end, back from the start) while the palette eases to its new height and the back chip pops in. Typing never moves anything. Opened by a press it grows out of what was pressed and closes back into it (_shared/use-open-from.ts); opened by ⌘K it appears in place. While results load, a short light runs along the field's bottom edge (a still line under reduced motion) and the list shows rows shaped like results. Reduced motion places everything at once.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
items | CommandItem[] ({ id, label, group?, icon?, shortcut?, keywords?, description?, disabled?, children?, onSelect? }) | — | |
onSelect | (item) => void | — | A chosen item without children. |
placeholder | string | — | |
emptyText | (query) => ReactNode | — | What to say when nothing matches. |
CommandMenu open / onOpenChange / hotkey | boolean | — | open: Controlled open state; omit to use defaultOpen. onOpenChange: Reports an open-state change; no callback by default. hotkey: ⌘K / Ctrl K opens and closes it. Default true. |
style / ref | CSSProperties / native Ref | — | style: Inline styles on the documented visual root; no overrides by default. ref: Receives the documented native target or imperative handle; omitted by default. |
classNames | CommandPaletteClassNames | — | Classes for the named visual parts; no overrides by default. |
overlayClassNames | Partial<Record<"root" | "scrim" | "title", string>> | — | |
loading | boolean | false | Results are still arriving (a search on the server): a busy line runs under the field, and while nothing has arrived the list shows rows shaped like results instead of "no match". |
onQueryChange | (query) => void | — | The search text as it changes (fetch results for it; a nested page starts empty). |
open | boolean | — | Controlled open state; omit to use defaultOpen. |
defaultOpen | boolean | — | Initial open state when uncontrolled; defaults to false. |
onOpenChange | ((open: boolean) => void) | — | Reports an open-state change; no callback by default. |
hotkey | boolean | — | ⌘K / Ctrl K opens and closes it. Default true. |
ref | Ref<HTMLDivElement> | — | Receives the documented native target or imperative handle; omitted by default. |
label | string | — | Accessible name of the search field. |
style | CSSProperties | — | Inline styles on the documented visual root; no overrides by default. |
className | string | — | Classes on the documented visual root; no override by default. |
CommandPalette.onClose | (() => void) | — | On CommandPalette: Escape on the first page. |
Built from
Used in
Dependencies
@radix-ui/react-dialog, lucide-react
Import
import { CommandPalette, CommandMenu } from "@beamline/command-menu";
Get it
Command menu is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. Command menu is included in the free MIT sample. Get Beamline · Connect your agent
More in Overlays
- Toast: Short results of an action stacked at an edge: point at the stack to fan it out and pause the timers; undo or retry in place; Alt+T, Escape and a swipe…
- Share dialog: Share a document, board or project: invite people by name or email with the access they get, change or remove anyone's access in place, and set who the…
- Context menu: Actions for an object on right-click, long-press, Shift+F10 or the menu key, opened at the pointer, with the same rows as the dropdown menu.
- Hover card: A preview of a person, link or record on hover or keyboard focus, without leaving the page; HoverCardProfile is the standard person preview.
- Product tour: A short guided tour over the real interface: a spotlight that glides from one element to the next while the rest of the screen dims, and a card beside…
- Bottom sheet: A phone panel that rests at a peek and follows the finger to full height; a flick down closes it, and the handle works from the keyboard.
- Sheet: A panel that slides in from an edge with the page still visible behind it: header and footer stay put while the body scrolls.
- Dropdown menu: A list of actions behind a trigger, with shortcuts, check items, headings and submenus; one highlight glides under the pointer and jumps with the keyboard.
- Dialog: A focused task over the page (create, invite, rename) with a title, body and footer; focus moves in, is trapped and returns on close.
- Alert Dialog: A blocking confirmation that must be answered: the scrim does not dismiss it, focus starts on the safe choice, and an async action keeps it open until…
- Popover: A small surface anchored to a trigger for a short form, a filter or an explanation; focus moves in and returns on close.
- Tooltip: Short supporting text for a control: opens after a moment on hover and at once on keyboard focus; inside a toolbar group the next one opens instantly.