VayuUI

CommandBox

A command palette for quick navigation, search, and actions with keyboard support.

Usage

Command Palette

Press Ctrl+Shift+P or click the button

Interactive

Use arrow keys to navigate, Enter to select, Escape to close

Inline CommandBox

Without overlay backdrop

Embedded

With Descriptions

Items with additional context

Simple List

Without groups or shortcuts

Loading State

Async command loading

Loading commands...
import { CommandBox } from "@/components/ui/commandbox"

const items = [
  { id: "home", title: "Go to Home", shortcut: ["⌘", "H"] },
  { id: "search", title: "Search", shortcut: ["⌘", "K"] },
]

export function Example() {
  return (
    <CommandBox
      items={items}
      onSelect={(item) => console.log(item.title)}
    />
  )
}

Installation

Copy the component file into your project:

src/components/ui/commandbox.tsx
// Copy the full component code

Features

  • Keyboard Navigation — Arrow keys, Enter to select, Escape to close
  • Search Filtering — Real-time filtering with pluggable filter function
  • Grouping — Auto-group items via group property or explicit groups prop
  • Shortcuts — Display keyboard shortcuts next to items
  • Variantsdefault, bordered, elevated, minimal

Props

CommandBox

PropTypeDefaultDescription
itemsCommandItem[][]Flat list of command items.
groupsCommandGroup[][]Grouped command items.
placeholderstring"Type a command or search..."Search input placeholder.
emptyTextstring"No results found."Text shown when no results match.
variantdefault | bordered | elevated | minimaldefaultVisual variant.
sizesmall | medium | largemediumSize of the command box.
openbooleanfalseControl open state.
onOpenChange(open: boolean) => voidCallback when open state changes.
onSelect(item: CommandItem) => voidCallback when an item is selected.
filter(value, search) => numberbuilt-inCustom filter function.
disabledbooleanfalseDisable the command box.
showShortcutsbooleantrueShow keyboard shortcuts on items.
maxHeightstring"400px"Max height of the dropdown.

CommandItem

PropertyTypeDescription
idstringUnique identifier.
titlestringDisplay title.
descriptionstringOptional description text.
iconReactNodeOptional icon element.
shortcutstring[]Keyboard shortcut keys to display.
groupstringGroup name for auto-grouping.
disabledbooleanDisable this item.
onSelect() => voidItem-level select callback.

On this page