Componentnavigation2.92 KB gzipZero dependencies

Command Palette

Modal search command palette with keyboard shortcuts, categorization, and filter.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add command-palette

Or install the full npm package:

npm install bigbullui

Usage

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 helpers

Zero 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 />
PropTypeDescription
openbooleanControlled open visibility state.
onOpenChange(open: boolean) => voidCallback invoked on open change.
itemsCommandItem[]Structured list of items rendered by the component. (Default: [])
placeholderstringPlaceholder text shown when empty. (Default: "Type a command or search tickets...")
synonymsRecord<string, string | string[]>Configures synonyms. (Default: EMPTY_SYNONYMS)
emptyTextstringConfigures empty text. (Default: "NO COMMANDS MATCHING QUERY")
navigateHintstringConfigures navigate hint. (Default: "Navigate: ↑↓")
selectHintstringConfigures select hint. (Default: "Select: ↵")