Command Palette
1 variante
Command palettes for finding pages and running actions, with grouped search, keyboard navigation, and polished open and selection motion.
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,
Building2,
FilePlus2,
Folder,
FolderPlus,
House,
Keyboard,
Laptop,
Moon,
Palette,
Search,
Settings2,
Sun,
UserPlus,
UsersRound,
} from "lucide-react";
import { useState } from "react";
import { Button } from "@/components/motion/button";
import {
CommandKbd,
type MorphicCommandItem,
MorphicCommandPalette,
MorphicCommandPaletteContent,
MorphicCommandPaletteTrigger,
} from "@/components/premium/command-palette";
const commands: MorphicCommandItem[] = [
{
id: "home",
label: "Home",
description: "Your overview and recent activity",
group: "Navigation",
icon: House,
keywords: ["dashboard", "overview"],
shortcut: ["G", "H"],
},
{
id: "projects",
label: "Projects",
description: "Every project in this workspace",
group: "Navigation",
icon: Folder,
shortcut: ["G", "P"],
},
{
id: "team",
label: "Team",
description: "Members, roles, and invites",
group: "Navigation",
icon: UsersRound,
keywords: ["members", "people"],
},
{
id: "settings",
label: "Settings",
group: "Navigation",
icon: Settings2,
keywords: ["preferences", "account"],
shortcut: ["⌘", ","],
},
{
id: "new-document",
label: "New document",
group: "Actions",
icon: FilePlus2,
keywords: ["create", "page", "write"],
shortcut: ["⌘", "N"],
},
{
id: "new-project",
label: "New project",
group: "Actions",
icon: FolderPlus,
keywords: ["create", "folder"],
shortcut: ["⌘", "⇧", "N"],
},
{
id: "invite",
label: "Invite a teammate",
group: "Actions",
icon: UserPlus,
keywords: ["add", "member"],
},
{
id: "theme",
label: "Change theme",
description: "Light, dark, or match your system",
group: "Preferences",
icon: Palette,
keywords: ["appearance", "mode"],
children: [
{ id: "theme-light", label: "Light", icon: Sun },
{ id: "theme-dark", label: "Dark", icon: Moon },
{ id: "theme-system", label: "System", icon: Laptop },
],
},
{
id: "workspace",
label: "Switch workspace",
group: "Preferences",
icon: Building2,
keywords: ["team", "organization"],
children: [
{
id: "ws-acme",
label: "Acme Studio",
description: "12 members",
icon: Building2,
},
{
id: "ws-north",
label: "Northwind",
description: "4 members",
icon: Building2,
},
{
id: "ws-personal",
label: "Personal",
description: "Just you",
icon: Building2,
},
],
},
{
id: "shortcuts",
label: "Keyboard shortcuts",
group: "Help",
icon: Keyboard,
keywords: ["help", "keys"],
shortcut: ["?"],
},
];
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={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>
);
}
Le code source est verrouillé
Obtenez un accès pour installer les composants premium et voir tout le code source.
Ouvrir le tableau de bordInstallation
$ bunx --bun shadcn add @beui-pro/morphic-command-palette