Componentnavigation2.92 KB gzipZero dependencies
Command Palette
Modal search command palette with keyboard shortcuts, categorization, and filter.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add command-paletteOr install the full npm package:
npm install bigbulluiUsage
tsx10 lines
import { CommandPalette } from "@/components/ui/command-palette"; <CommandPalette open={open} onOpenChange={setOpen} items={[ { id: "1", label: "Print Stubs", shortcut: "⌘P", onSelect: () => {} }, { id: "2", label: "Seat Map", shortcut: "⌘M", onSelect: () => {} }, ]}/>Source code
command-palette.tsx + 3 helpersZero third-party dependencies (4 local files shown in tabs below).
tsxcommand-palette.tsx396 lines
"use client"; import * as React from "react";import { createPortal } from "react-dom";import { cn } from "./lib/utils";import { getFocusable, hideBackgroundSiblings, lockBodyScroll, registerEscapeLayer, trapFocus,} from "./lib/focus-trap";import { useIsMounted } from "./lib/react-compat"; export interface CommandItem { id: string; label: string; category?: string;Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { CommandPalette } from "@/components/ui/command-palette"; <CommandPalette />| Prop | Type | Description |
|---|---|---|
| open | boolean | Controlled open visibility state. |
| onOpenChange | (open: boolean) => void | Callback invoked on open change. |
| items | CommandItem[] | Structured list of items rendered by the component. (Default: []) |
| placeholder | string | Placeholder text shown when empty. (Default: "Type a command or search tickets...") |
| synonyms | Record<string, string | string[]> | Configures synonyms. (Default: EMPTY_SYNONYMS) |
| emptyText | string | Configures empty text. (Default: "NO COMMANDS MATCHING QUERY") |
| navigateHint | string | Configures navigate hint. (Default: "Navigate: ↑↓") |
| selectHint | string | Configures select hint. (Default: "Select: ↵") |