Command Palette
2 バリエーション
Command palettes for finding pages and running actions, with grouped search, keyboard navigation, and polished open and selection motion.
Dialog command palette
dialog-command-palette.tsxA 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.
TSXcomponents/previews/premium/command-palette-dialog-preview.tsx
"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>
);
}
インストール
$ bunx --bun shadcn add @beui-pro/dialog-command-palette
Morphic command palette
morphic-command-palette.tsxA 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.
TSXcomponents/previews/premium/command-palette-morphic-preview.tsx
"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>
);
}
インストール
$ bunx --bun shadcn add @beui-pro/morphic-command-palette