BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/jolyui/ui/command-palette

command-palette

jolyui-ui/command-palette
FreeComponent

jolyui/ui publishes no description for this item.

Live preview

live · rendered by the registry
Rendered by jolyui/ui on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://jolyui.dev/r/command-palette.json

Source

ui/command-palette.tsxjolyui.dev/r/command-palette.json · first 6 KB
1"use client";
2
3import {
4 ChevronRight,
5 Clock,
6 CornerDownLeft,
7 Loader2,
8 type LucideIcon,
9 Search,
10 X,
11} from "lucide-react";
12import { AnimatePresence, LayoutGroup, motion } from "motion/react";
13import type React from "react";
14import { useCallback, useEffect, useMemo, useRef, useState } from "react";
15import { cn } from "@/lib/utils";
16
17export interface CommandItem {
18 id: string;
19 label: string;
20 description?: string;
21 icon?: LucideIcon;
22 shortcut?: string[];
23 keywords?: string[];
24 onSelect?: () => void;
25 children?: CommandGroup[]; // Support for sub-menus
26 disabled?: boolean;
27}
28
29export interface CommandGroup {
30 id: string;
31 heading: string;
32 items: CommandItem[];
33}
34
35export interface CommandPaletteProps {
36 open?: boolean;
37 onOpenChange?: (open: boolean) => void;
38 groups: CommandGroup[];
39 placeholder?: string;
40 emptyMessage?: string;
41 shortcut?: string[];
42 loading?: boolean;
43 showRecent?: boolean;
44 maxRecent?: number;
45}
46
47interface FlattenedItem {
48 type: "group" | "item";
49 groupId: string;
50 groupHeading?: string;
51 item?: CommandItem;
52 score?: number;
53 matches?: [number, number][];
54}
55
56interface PageState {
57 id: string;
58 title: string;
59 groups: CommandGroup[];
60}
61
62export function CommandPalette({
63 open: controlledOpen,
64 onOpenChange,
65 groups: initialGroups,
66 placeholder = "Type a command or search...",
67 emptyMessage = "No results found.",
68 shortcut = ["⌘", "K"],
69 loading = false,
70 showRecent = true,
71 maxRecent = 5,
72}: CommandPaletteProps) {
73 const [internalOpen, setInternalOpen] = useState(false);
74 const [query, setQuery] = useState("");
75 const [selectedIndex, setSelectedIndex] = useState(0);
76 const [pages, setPages] = useState<PageState[]>([
77 { id: "root", title: "Root", groups: initialGroups },
78 ]);
79 const [recentItems, setRecentItems] = useState<CommandItem[]>([]);
80
81 const inputRef = useRef<HTMLInputElement>(null);
82 const listRef = useRef<HTMLDivElement>(null);
83 const itemRefs = useRef<Map<number, HTMLDivElement>>(new Map());
84
85 const isOpen = controlledOpen ?? internalOpen;
86 const setOpen = onOpenChange ?? setInternalOpen;
87 const currentPage = pages[pages.length - 1] || pages[0];
88
89 // Load recent items from localStorage
90 useEffect(() => {
91 if (typeof window !== "undefined") {
92 const saved = localStorage.getItem("jolyui-command-recent");
93 if (saved) {
94 try {
95 setRecentItems(JSON.parse(saved));
96 } catch (e) {
97// … truncated

What it pulls in

npm packages

  • lucide-react
  • motion

Files it writes

  • ui/command-palette.tsx

Facts

Registry
jolyui/ui
Type
registry:ui
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-02
Last confirmed
yesterday

Go to the source

Docs on jolyui/ui jolyui.dev Johuniq/jolyui on GitHub Raw registry item This item as JSON

More from jolyui/ui

All 199 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
ai-prompt-boxai-prompt-boxjolyui/uiComponentsFree4 deps
animated-beamanimated-beamjolyui/uiComponentsFree1 dep
animated-tableanimated-tablejolyui/uiComponentsFree2 deps
animated-theme-toggleanimated-theme-togglejolyui/uiComponentsFree2 deps
animated-toastanimated-toastjolyui/uiComponentsFree2 deps
animated-tooltipanimated-tooltipjolyui/uiComponentsFree1 dep
bento-gridbento-gridjolyui/uiComponentsFreeno deps
buttonbuttonjolyui/uiComponentsFree3 deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex