Command
blok/commandFreeComponent
Fast, composable, unstyled command menu for React.
Install it
npx shadcn@latest add https://blok.sitecore.com/r/command.jsonSource
1"use client";23import { Icon } from "@/lib/icon";4import { mdiClose, mdiMagnify } from "@mdi/js";5import { Command as CommandPrimitive } from "cmdk";6import { Dialog as DialogPrimitive } from "radix-ui";7import * as React from "react";89import { Button } from "@/components/ui/button";10import {11 Dialog,12 DialogContent,13 DialogDescription,14 DialogHeader,15 DialogTitle,16} from "@/components/ui/dialog";17import { cn } from "@/lib/utils";1819function Command({20 className,21 ...props22}: React.ComponentProps<typeof CommandPrimitive>) {23 return (24 <CommandPrimitive25 data-slot="command"26 className={cn(27 "bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",28 className,29 )}30 {...props}31 />32 );33}3435function CommandDialog({36 title = "Command Palette",37 description = "Search for a command to run...",38 children,39 ...props40}: React.ComponentProps<typeof Dialog> & {41 title?: string;42 description?: string;43}) {44 return (45 <Dialog {...props}>46 <DialogHeader className="sr-only">47 <DialogTitle>{title}</DialogTitle>48 <DialogDescription>{description}</DialogDescription>49 </DialogHeader>50 <DialogContent className="overflow-hidden p-0">51 <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]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">52 {children}53 <DialogPrimitive.Close style={{ display: "none" }} />54 </Command>55 </DialogContent>56 </Dialog>57 );58}5960function CommandInput({61 className,62 ...props63}: React.ComponentProps<typeof CommandPrimitive.Input>) {64 const [value, setValue] = React.useState("");6566 const handleClear = () => {67 setValue("");68 };6970 return (71 <div data-slot="command-input-wrapper" className="relative my-2 px-3">72 <CommandPrimitive.Input73 value={value}74 onValueChange={setValue}75 data-slot="command-input"76 aria-label={props["aria-label"] || "Search commands"}77 className={cn(78// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from blok
All 72 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | blok | Components | Free | 2 deps · 2 files | |
| Action baraction-bar | blok | Components | Free | 1 dep · 2 files | |
| Alertalert | blok | Components | Free | 2 deps · 2 files | |
| Alert dialogalert-dialog | blok | Components | Free | 2 deps | |
| Aspect ratioaspect-ratio | blok | Components | Free | 1 dep | |
| Avataravatar | blok | Components | Free | 1 dep | |
| Badgebadge | blok | Components | Free | 2 deps | |
| All componentsblok-components | blok | Components | Free | no deps |
