Command Palette
2 variantsCommand 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>
);
}
Source code is locked
Get access to install premium components and view the full source.
Open dashboardInstall
API Reference
Every prop is optional unless marked required. Data, copy, and colors default to the sample content.
CommandPaletteDialogContent6 props
titleScreen-reader dialog title. Defaults to the title label.
stringplaceholderSearch placeholder on the top page. Defaults to the placeholder label.
stringemptyMessageReplaces the default "No results for …" line.
stringemptyActionShown under the empty state, such as a "Search docs" button.
ReactNodefooterReplaces the key hints and result count.
ReactNodeclassNameClasses merged onto the root element.
string
CommandPaletteTrigger3 props
classNameClasses merged onto the root element.
stringsizeHeight and padding: sm, md, lg, or icon for a square icon button.
"sm" | "md" | "lg" | "icon"pressScaleScale while pressed, skipped with reduced motion. Defaults to 0.99.
number
MorphicCommandPalette9 props
itemsRequiredCommands listed in the palette, with optional nested pages.
readonly MorphicCommandItem[]openControlled open state.
booleandefaultOpenInitial open state when uncontrolled.
booleanDefault
falseonOpenChangeCalled with the next open state when the palette opens or closes.
((open: boolean) => void)onSelectCalled with the item after a command without children runs.
((item: MorphicCommandItem) => void)shortcutCmd/Ctrl + this key. Pass false to disable the global shortcut.
string | falseDefault
kdefaultRecentIds shown under "Recent" before the first search.
string[]Default
[]recentLimitHow many recent commands to keep. 0 turns the section off.
numberDefault
3labelsOverrides 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>
);
}
Source code is locked
Get access to install premium components and view the full source.
Open dashboardInstall
API Reference
Every prop is optional unless marked required. Data, copy, and colors default to the sample content.
MorphicCommandPalette9 props
itemsRequiredCommands listed in the palette, with optional nested pages.
readonly MorphicCommandItem[]openControlled open state.
booleandefaultOpenInitial open state when uncontrolled.
booleanDefault
falseonOpenChangeCalled with the next open state when the palette opens or closes.
((open: boolean) => void)onSelectCalled with the item after a command without children runs.
((item: MorphicCommandItem) => void)shortcutCmd/Ctrl + this key. Pass false to disable the global shortcut.
string | falseDefault
kdefaultRecentIds shown under "Recent" before the first search.
string[]Default
[]recentLimitHow many recent commands to keep. 0 turns the section off.
numberDefault
3labelsOverrides 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
titleScreen-reader dialog title. Defaults to the title label.
stringplaceholderSearch placeholder on the top page. Defaults to the placeholder label.
stringemptyMessageReplaces the default "No results for …" line.
stringemptyActionShown under the empty state, such as a "Search docs" button.
ReactNodefooterReplaces the key hints and result count.
ReactNodeclassNameClasses merged onto the root element.
string
MorphicCommandPaletteTrigger3 props
classNameClasses merged onto the root element.
stringsizeHeight and padding: sm, md, lg, or icon for a square icon button.
"sm" | "md" | "lg" | "icon"pressScaleScale while pressed, skipped with reduced motion. Defaults to 0.99.
number
Types1 type
The object types these props take, field by field.
MorphicCommandItem10 fields
idRequiredStable and unique across the palette, nested items included.
stringlabelRequiredRow text, matched by search and marked where it matches.
stringdescriptionSecondary line on the row, also matched by search.
stringgroupGroup heading for top-level items. Defaults to the commands label.
stringiconIcon in the row chip. Defaults to a command icon.
LucideIconkeywordsExtra search terms that match the item without being shown.
string[]shortcutKeys shown as chips, such as ["⌘", "⇧", "N"]. Display only.
string[]hintDisplay hint only; prefer `shortcut` for keys.
stringchildrenSub-commands. Selecting this item opens them as a page.
MorphicCommandItem[]onSelectCalled 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
keysRequiredKeys rendered as chips in order, such as ["⌘", "K"].
readonly string[]classNameClasses merged onto the root element.
string