From 897e9add14b2b1ab6a206ebafdeb2c9491314fe1 Mon Sep 17 00:00:00 2001 From: shadcn Date: Mon, 29 Jun 2026 21:30:46 +0400 Subject: [PATCH] feat(command-menu): add styles group linking to shadcn/create (#11052) Co-authored-by: Claude Opus 4.8 (1M context) --- apps/v4/components/command-menu.tsx | 40 ++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/apps/v4/components/command-menu.tsx b/apps/v4/components/command-menu.tsx index 10dbab8584..77d49b44ad 100644 --- a/apps/v4/components/command-menu.tsx +++ b/apps/v4/components/command-menu.tsx @@ -6,6 +6,7 @@ import { IconArrowRight } from "@tabler/icons-react" import { useDocsSearch } from "fumadocs-core/search/client" import { CornerDownLeftIcon, SquareDashedIcon } from "lucide-react" import { Dialog as DialogPrimitive } from "radix-ui" +import { encodePreset } from "shadcn/preset" import { type Color, type ColorPalette } from "@/lib/colors" import { trackEvent } from "@/lib/events" @@ -36,6 +37,7 @@ import { } from "@/registry/new-york-v4/ui/dialog" import { Separator } from "@/registry/new-york-v4/ui/separator" import { Spinner } from "@/registry/new-york-v4/ui/spinner" +import { STYLES } from "@/registry/styles" export function CommandMenu({ tree, @@ -56,7 +58,7 @@ export function CommandMenu({ const [open, setOpen] = React.useState(false) const [renderDelayedGroups, setRenderDelayedGroups] = React.useState(false) const [selectedType, setSelectedType] = React.useState< - "color" | "page" | "component" | "block" | null + "color" | "page" | "component" | "block" | "style" | null >(null) const [copyPayload, setCopyPayload] = React.useState("") @@ -208,6 +210,40 @@ export function CommandMenu({ ) }, [navItems, runCommand, router]) + const stylesSection = React.useMemo(() => { + return ( + + {STYLES.map((style) => ( + { + setSelectedType("style") + setCopyPayload("") + }} + onSelect={() => { + runCommand(() => + router.push( + `/create?preset=${encodePreset({ style: style.name })}` + ) + ) + }} + > + {style.icon} + {style.title} + + Open style in shadcn/create + + + ))} + + ) + }, [runCommand, router]) + const pageGroupsSection = React.useMemo(() => { return tree.children.map((group) => { if (group.type !== "folder") { @@ -425,6 +461,7 @@ export function CommandMenu({ {query.isLoading ? "Searching..." : "No results found."} {navItemsSection} + {stylesSection} {renderDelayedGroups ? ( <> {pageGroupsSection} @@ -448,6 +485,7 @@ export function CommandMenu({ ? "Go to Page" : null} {selectedType === "color" ? "Copy OKLCH" : null} + {selectedType === "style" ? "Open in shadcn/create" : null} {copyPayload && ( <>