Command
nivalis-ui/commandFreeComponent
A command component.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/nivalis-studio/nivalis-ui/main/public/r/command.jsonSource
1'use client';23import { Command as CommandPrimitive } from 'cmdk';4import { SearchIcon } from 'lucide-react';5import { cn } from '@/lib/classnames';6import { Dialog } from '@/registry/niv/ui/dialog';7import type { ComponentProps } from 'react';89function CommandRoot({10 className,11 ...props12}: ComponentProps<typeof CommandPrimitive>) {13 return (14 <CommandPrimitive15 className={cn(16 'flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground',17 className,18 )}19 data-slot='command'20 {...props}21 />22 );23}2425function CommandDialog({26 title = 'Command Palette',27 description = 'Search for a command to run...',28 children,29 className,30 showCloseButton = true,31 ...props32}: ComponentProps<typeof Dialog> & {33 title?: string;34 description?: string;35 className?: string;36 showCloseButton?: boolean;37}) {38 return (39 <Dialog {...props}>40 <Dialog.Header className='sr-only'>41 <Dialog.Title>{title}</Dialog.Title>42 <Dialog.Description>{description}</Dialog.Description>43 </Dialog.Header>44 <Dialog.Content45 className={cn('overflow-hidden p-0', className)}46 showCloseButton={showCloseButton}47 >48 <Command className='**:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[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'>49 {children}50 </Command>51 </Dialog.Content>52 </Dialog>53 );54}5556function CommandInput({57 className,58 ...props59}: ComponentProps<typeof CommandPrimitive.Input>) {60 return (61 <div62 className='flex h-9 items-center gap-2 border-b px-3'63 data-slot='command-input-wrapper'64 >65 <SearchIcon className='size-4 shrink-0 opacity-50' />66 <CommandPrimitive.Input67 className={cn(68 'flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50',69 className,70 )}71 data-slot='command-input'72 {...props}73 />74 </div>75 );76}7778function CommandList({79 className,80 ...props81}: ComponentProps<typeof CommandPrimitive.List>) {82 return (83 <CommandPrimitive.List84// … truncated
What it pulls in
npm packages
Files it writes
More from @nivalis/ui
All 23 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | @nivalis/ui | Components | Free | 1 dep | |
| Avataravatar | @nivalis/ui | Components | Free | 1 dep | |
| Badgebadge | @nivalis/ui | Components | Free | no deps | |
| Breadcrumbbreadcrumb | @nivalis/ui | Components | Free | 1 dep | |
| Buttonbutton | @nivalis/ui | Components | Free | 1 dep | |
| Cardcard | @nivalis/ui | Components | Free | no deps | |
| Checkboxcheckbox | @nivalis/ui | Components | Free | 1 dep | |
| ContextMenucontext-menu | @nivalis/ui | Components | Free | 1 dep |
