Command Palette

2 variants

Command palettes for finding pages and running actions, with grouped search, keyboard navigation, and polished open and selection motion.

Dialog command palette

A palette in a plain dialog near the top of the screen, with recent commands, marked search matches, shortcut key chips, and sub-pages that slide in with a breadcrumb. The trigger stays put while the panel grows out of it, or out of the focused element when opened with the shortcut.

"use client";

import { BookOpen, Search } from "lucide-react";
import { useState } from "react";
import { Button } from "@/components/motion/button";
import {
  CommandKbd,
  CommandPalette,
  CommandPaletteDialogContent,
  CommandPaletteTrigger,
} from "@/components/premium/command-palette";
import { SAMPLE_COMMANDS } from "./command-palette-sample";

export function CommandPaletteDialogPreview() {
  const [selected, setSelected] = useState("");

  return (
    <div className="flex min-h-80 w-full flex-col items-center justify-center gap-3 p-6">
      <CommandPalette
        items={SAMPLE_COMMANDS}
        // ⌘K belongs to the site's own search; ⌘J is the morphic preview's.
        shortcut="/"
        defaultRecent={["projects", "invite"]}
        onSelect={(item) => setSelected(item.label)}
      >
        <CommandPaletteTrigger className="w-full max-w-xs">
          <Search aria-hidden className="size-4 text-muted-foreground" />
          <span className="flex-1 text-left text-muted-foreground">
            Search or jump to…
          </span>
          <CommandKbd keys={["⌘", "/"]} />
        </CommandPaletteTrigger>
        <CommandPaletteDialogContent
          emptyAction={
            <Button variant="outline" size="sm" className="h-8 px-3 text-xs">
              <BookOpen aria-hidden className="size-3.5" />
              Search the docs
            </Button>
          }
        />
      </CommandPalette>
      <output className="min-h-4 text-muted-foreground text-xs">
        {selected ? `Ran: ${selected}` : ""}
      </output>
    </div>
  );
}

Install

$ bunx --bun shadcn add @beui-pro/dialog-command-palette

API Reference

Every prop is optional unless marked required. Data, copy, and colors default to the sample content.

CommandPaletteDialogContent6 props
  • title

    Screen-reader dialog title. Defaults to the title label.

    string
  • placeholder

    Search placeholder on the top page. Defaults to the placeholder label.

    string
  • emptyMessage

    Replaces the default "No results for …" line.

    string
  • emptyAction

    Shown under the empty state, such as a "Search docs" button.

    ReactNode
  • footer

    Replaces the key hints and result count.

    ReactNode
  • className

    Classes merged onto the root element.

    string
CommandPaletteTrigger3 props
  • className

    Classes merged onto the root element.

    string
  • size

    Height and padding: sm, md, lg, or icon for a square icon button.

    "sm" | "md" | "lg" | "icon"
  • pressScale

    Scale while pressed, skipped with reduced motion. Defaults to 0.99.

    number
MorphicCommandPalette9 props
  • itemsRequired

    Commands listed in the palette, with optional nested pages.

    readonly MorphicCommandItem[]
  • open

    Controlled open state.

    boolean
  • defaultOpen

    Initial open state when uncontrolled.

    boolean

    Default false

  • onOpenChange

    Called with the next open state when the palette opens or closes.

    ((open: boolean) => void)
  • onSelect

    Called with the item after a command without children runs.

    ((item: MorphicCommandItem) => void)
  • shortcut

    Cmd/Ctrl + this key. Pass false to disable the global shortcut.

    string | false

    Default k

  • defaultRecent

    Ids shown under "Recent" before the first search.

    string[]

    Default []

  • recentLimit

    How many recent commands to keep. 0 turns the section off.

    number

    Default 3

  • labels

    Overrides for interface copy.

    Partial<{ title: string; placeholder: string; pagePlaceholder: string; searchIn: string; emptyTitle: string; emptyHint: string; recent: string; commands: string; navigate: string; select: string; back: string; ... 4 more ...; found: string; }>

Morphic command palette

A palette that morphs out of its trigger, with recent commands, marked search matches, shortcut key chips, sub-pages that slide in with a breadcrumb, and an empty state with a fallback action.

"use client";

import { BookOpen, Search } from "lucide-react";
import { useState } from "react";
import { Button } from "@/components/motion/button";
import {
  CommandKbd,
  MorphicCommandPalette,
  MorphicCommandPaletteContent,
  MorphicCommandPaletteTrigger,
} from "@/components/premium/command-palette";
import { SAMPLE_COMMANDS } from "./command-palette-sample";

export function MorphicCommandPalettePreview() {
  const [selected, setSelected] = useState("");

  return (
    <div className="flex min-h-80 w-full flex-col items-center justify-center gap-3 p-6">
      <MorphicCommandPalette
        items={SAMPLE_COMMANDS}
        shortcut="j"
        defaultRecent={["new-document", "theme"]}
        onSelect={(item) => setSelected(item.label)}
      >
        <MorphicCommandPaletteTrigger className="h-10 w-full max-w-xs">
          <Search aria-hidden className="size-4 text-muted-foreground" />
          <span className="flex-1 text-left text-muted-foreground">
            Search or jump to…
          </span>
          <CommandKbd keys={["⌘", "J"]} />
        </MorphicCommandPaletteTrigger>
        <MorphicCommandPaletteContent
          emptyAction={
            <Button variant="outline" size="sm" className="h-8 px-3 text-xs">
              <BookOpen aria-hidden className="size-3.5" />
              Search the docs
            </Button>
          }
        />
      </MorphicCommandPalette>
      <output className="min-h-4 text-muted-foreground text-xs">
        {selected ? `Ran: ${selected}` : ""}
      </output>
    </div>
  );
}

Install

$ bunx --bun shadcn add @beui-pro/morphic-command-palette

API Reference

Every prop is optional unless marked required. Data, copy, and colors default to the sample content.

MorphicCommandPalette9 props
  • itemsRequired

    Commands listed in the palette, with optional nested pages.

    readonly MorphicCommandItem[]
  • open

    Controlled open state.

    boolean
  • defaultOpen

    Initial open state when uncontrolled.

    boolean

    Default false

  • onOpenChange

    Called with the next open state when the palette opens or closes.

    ((open: boolean) => void)
  • onSelect

    Called with the item after a command without children runs.

    ((item: MorphicCommandItem) => void)
  • shortcut

    Cmd/Ctrl + this key. Pass false to disable the global shortcut.

    string | false

    Default k

  • defaultRecent

    Ids shown under "Recent" before the first search.

    string[]

    Default []

  • recentLimit

    How many recent commands to keep. 0 turns the section off.

    number

    Default 3

  • labels

    Overrides for interface copy.

    Partial<{ title: string; placeholder: string; pagePlaceholder: string; searchIn: string; emptyTitle: string; emptyHint: string; recent: string; commands: string; navigate: string; select: string; back: string; ... 4 more ...; found: string; }>
MorphicCommandPaletteContent6 props
  • title

    Screen-reader dialog title. Defaults to the title label.

    string
  • placeholder

    Search placeholder on the top page. Defaults to the placeholder label.

    string
  • emptyMessage

    Replaces the default "No results for …" line.

    string
  • emptyAction

    Shown under the empty state, such as a "Search docs" button.

    ReactNode
  • footer

    Replaces the key hints and result count.

    ReactNode
  • className

    Classes merged onto the root element.

    string
MorphicCommandPaletteTrigger3 props
  • className

    Classes merged onto the root element.

    string
  • size

    Height and padding: sm, md, lg, or icon for a square icon button.

    "sm" | "md" | "lg" | "icon"
  • pressScale

    Scale while pressed, skipped with reduced motion. Defaults to 0.99.

    number
Types1 type

The object types these props take, field by field.

MorphicCommandItem10 fields
  • idRequired

    Stable and unique across the palette, nested items included.

    string
  • labelRequired

    Row text, matched by search and marked where it matches.

    string
  • description

    Secondary line on the row, also matched by search.

    string
  • group

    Group heading for top-level items. Defaults to the commands label.

    string
  • icon

    Icon in the row chip. Defaults to a command icon.

    LucideIcon
  • keywords

    Extra search terms that match the item without being shown.

    string[]
  • shortcut

    Keys shown as chips, such as ["⌘", "⇧", "N"]. Display only.

    string[]
  • hint

    Display hint only; prefer `shortcut` for keys.

    string
  • children

    Sub-commands. Selecting this item opens them as a page.

    MorphicCommandItem[]
  • onSelect

    Called when the item runs. Items with children open a page instead.

    () => void

Shared parts

Components and types this folder exports that no single variant installs on its own.

CommandKbd2 props
  • keysRequired

    Keys rendered as chips in order, such as ["⌘", "K"].

    readonly string[]
  • className

    Classes merged onto the root element.

    string