39 Pro components and page blocks

Get Pro

Command Menu

Preview

Customize

Width580px
Recents4

Usage

import { CommandMenu } from "@/components/uibrik/command-menu/command-menu";

<CommandMenu />

Installation

npx shadcn@latest add https://uibrik.com/r/command-menu.json
Adds the files to components/uibrik/command-menu and installs @tabler/icons-react and motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/command-menu.

Props

CommandMenu
placeholder
Type string
"Search docs and components"
Text in the empty field and on the trigger.
shortcut
Type string
"k"
Key that toggles the menu with ⌘ / Ctrl. Empty turns the shortcut off.
showFilters
Type boolean
true
Show the filter pills. Tab cycles them from the keyboard.
highlight
Type boolean
true
Bold the letters of the label that matched the search.
footer
Type boolean
true
Keyboard hints and the result count under the list.
blur
Type boolean
true
Blur the page behind the menu.
width
Type number
580
Widest the menu gets.
hotkeys
Type boolean
true
Run an item's shortcut from anywhere on the page while the menu is closed.
maxRecents
Type number
4
Recently run commands listed first while the field is empty. 0 turns them off.
items
Type CommandItem[]
SAMPLE_ITEMS
What the menu can find or run: { id, label, type, icon?, description?, keywords?, shortcut?, disabled?, children?, onSelect? }. Give an item children to open a nested page.
filters
Type CommandFilter[]
SAMPLE_FILTERS
Filter pills and group headings, as { id, label }. An item's type picks its filter.
onSearch
Type (query: string, signal: AbortSignal) => Promise<CommandItem[]>
–
Fetches results from a server as the user types, shown beside the local ones. Called once typing pauses; abort the signal when a newer search starts. The demo searches a fake customer list this way.
searchDelay
Type number
200
Wait after the last keystroke before calling onSearch, in ms.
maxResults
Type number
100
Most rows shown at once. Longer lists are cut off; searching narrows them.
renderItem
Type (item: CommandItem, state: { active: boolean; label: ReactNode }) => ReactNode
–
Draws a row's contents yourself, e.g. a status badge or an amount. The row's highlight, height and click stay.
labels
Type Partial<CommandLabels>
DEFAULT_LABELS
Replaces any of the menu's text, for translation or your own wording.
open
Type boolean
–
Controlled open state. Leave out to let the menu keep its own.
defaultOpen
Type boolean
false
Whether it starts open.
onOpenChange
Type (open: boolean) => void
–
Called when the menu opens or closes.
onSelect
Type (item: CommandItem) => void
–
Called after a command runs, alongside its own onSelect.
recentsKey
Type string
"command-menu-recents"
localStorage key for recents.
className
Type string
–
Classes for the trigger button.