V-/Srcv0.1.0beta
// command
cmdk in a glass panel. Press ⌘K anywhere on this site — the palette is the same registry component.
npx shadcn add @vsrc/commandOnly the vsrc surface is documented here. Everything else passes through to the underlying element.
// CommandDialog
| prop | type | default | notes |
|---|---|---|---|
| open / onOpenChange | boolean / (open: boolean) => void | — | Controlled open state, passed through to the underlying Dialog. |
The glass is the Dialog pane; everything inside — input, list, items — is flat. Never nest glass.
The exact file the CLI copies into your project — you own it after install.
"use client";
import * as React from "react";
import { Command as CommandPrimitive } from "cmdk";
import {
Dialog,
DialogContent,
DialogDescription,
DialogTitle,
} from "@/registry/vsrc/ui/dialog";
import { cn } from "@/lib/utils";
// The glass is the Dialog panel; everything inside is flat — never nest glass.
function Command({ className, ...props }: React.ComponentProps<typeof CommandPrimitive>) {
return (
<CommandPrimitive
data-slot="command"
className={cn("flex h-full w-full flex-col overflow-hidden text-foreground", className)}
{...props}
/>
);
}
function CommandDialog({
title = "Command palette",
description = "Search for a component or an action.",
children,
...props
}: React.ComponentProps<typeof Dialog> & { title?: string; description?: string }) {
return (
<Dialog {...props}>
{/* The palette owns its own chrome, so the Dialog drops its ✕ and padding. */}
<DialogContent showCloseButton={false} className="max-w-lg gap-0 overflow-hidden p-0">
<DialogTitle className="sr-only">{title}</DialogTitle>
<DialogDescription className="sr-only">{description}</DialogDescription>
<Command>{children}</Command>
</DialogContent>
</Dialog>
);
}
function CommandInput({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Input>) {
return (
<div data-slot="command-input-wrapper" className="flex items-center gap-2 border-b border-foreground/10 px-4">
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5" className="size-4 shrink-0 text-muted-foreground">
<circle cx="7" cy="7" r="4.5" />
<path d="m11 11 3 3" />
</svg>
<CommandPrimitive.Input
data-slot="command-input"
className={cn(
"h-12 w-full bg-transparent text-sm text-foreground outline-none",
"placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
className,
)}
{...props}
/>
</div>
);
}
function CommandList({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.List>) {
return (
<CommandPrimitive.List
data-slot="command-list"
className={cn("max-h-80 overflow-x-hidden overflow-y-auto p-1.5", className)}
{...props}
/>
);
}
function CommandEmpty(props: React.ComponentProps<typeof CommandPrimitive.Empty>) {
return (
<CommandPrimitive.Empty
data-slot="command-empty"
className="py-6 text-center text-sm text-muted-foreground"
{...props}
/>
);
}
function CommandGroup({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Group>) {
return (
<CommandPrimitive.Group
data-slot="command-group"
className={cn(
"text-foreground",
"[&_[cmdk-group-heading]]:px-3 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:font-mono",
"[&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:tracking-widest",
"[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:uppercase",
className,
)}
{...props}
/>
);
}
function CommandItem({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Item>) {
return (
<CommandPrimitive.Item
data-slot="command-item"
className={cn(
"flex cursor-default items-center gap-2 rounded-[calc(var(--glass-radius)-8px)] px-3 py-2 text-sm",
"outline-none select-none data-[selected=true]:bg-foreground/15",
"data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50",
"[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
className,
)}
{...props}
/>
);
}
function CommandSeparator({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Separator>) {
return (
<CommandPrimitive.Separator
data-slot="command-separator"
className={cn("mx-2 my-1 h-px bg-foreground/15", className)}
{...props}
/>
);
}
function CommandShortcut({ className, ...props }: React.ComponentProps<"span">) {
return (
<span
data-slot="command-shortcut"
className={cn("ml-auto font-mono text-xs tracking-widest text-muted-foreground", className)}
{...props}
/>
);
}
export {
Command,
CommandDialog,
CommandInput,
CommandList,
CommandEmpty,
CommandGroup,
CommandItem,
CommandSeparator,
CommandShortcut,
};