Command
optics/commandFreeComponent
Fast, composable, unstyled command menu for React.
See it running
Open the demo on optics
optics.agusmayol.com.ar/components/commandInstall it
npx shadcn@latest add https://optics.agusmayol.com.ar/r/command.jsonSource
1"use client";23import * as React from "react";4import { Command as CommandPrimitive } from "cmdk";56import { cn } from "@/lib/utils";7import {8 Dialog,9 DialogPopup,10 DialogDescription,11 DialogHeader,12 DialogTitle,13} from "@/registry/optics/dialog";14import { ScrollArea } from "@/registry/optics/scroll-area";15import { SearchIcon } from "lucide-react";1617function Command({ className = "", ...props }) {18 return (19 <CommandPrimitive20 data-slot="command"21 className={cn(22 "bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-2xl",23 className,24 )}25 {...props}26 />27 );28}2930function CommandDialog({31 title = "Command Palette",32 description = "Search for a command to run...",33 children = null,34 className = "",35 showCloseButton = false,36 ...props37}) {38 return (39 <Dialog {...props}>40 <DialogHeader className="sr-only">41 <DialogTitle>{title}</DialogTitle>42 <DialogDescription>{description}</DialogDescription>43 </DialogHeader>44 <DialogPopup45 className={cn("overflow-hidden", className)}46 showCloseButton={showCloseButton}47 containerClassName="p-0"48 >49 <Command className="[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">50 {children}51 </Command>52 </DialogPopup>53 </Dialog>54 );55}5657function CommandInput({ className = "", ...props }) {58 return (59 <div60 data-slot="command-input-wrapper"61 className="flex h-9 items-center gap-2 border-b px-3 bg-background"62 >63 <SearchIcon className="size-4 shrink-0 opacity-50" />64 <CommandPrimitive.Input65 data-slot="command-input"66 className={cn(67 "placeholder:text-muted-foreground flex h-10 w-full rounded-xl bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",68 className,69 )}70 {...props}71 />72 </div>73 );74}7576function CommandList({ className = "", ...props }) {77 return (78 <ScrollArea79 className={cn("max-h-[300px]", className)}80 viewportClassName="scroll-py-1"81 >82 <CommandPrimitive.List83 data-slot="command-list"84 className="overflow-x-hidden"85 {...props}86 />87 </ScrollArea>88 );89}9091function CommandEmpty({ ...props } = {}) {92// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from optics
All 79 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | optics | Components | Free | 5 deps | |
| Alertalert | optics | Components | Free | 4 deps | |
| Alert Dialogalert-dialog | optics | Components | Free | 4 deps | |
| Aspect Ratioaspect-ratio | optics | Components | Free | 2 deps | |
| Auto Heightauto-height | optics | Components | Free | 3 deps | |
| Avataravatar | optics | Components | Free | 3 deps | |
| Badgebadge | optics | Components | Free | 4 deps | |
| Breadcrumbbreadcrumb | optics | Components | Free | 4 deps |
