Component Library
Browse and explore components
Command
A Command is a UI component that provides a searchable list of actions or commands for quick access.
Basic Command
No results found.
Calendar
Search Emoji
Calculator
Profile⌘P
Billing⌘B
Settings⌘S
Component Code
Copy Code
import React from 'react'
import {
Calculator,
Calendar,
CreditCard,
Settings,
Smile,
User,
} from 'lucide-react'
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
CommandShortcut,
} from '@/components/ui/command'
const BasicCommandCode = () => {
return (
<>
<Command className='rounded-lg border border-ld dark:border-gray-600 mt-4'>
<CommandInput placeholder='Type a command or search...' />
<CommandList>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup heading='Suggestions'>
<CommandItem>
<Calendar />
<span>Calendar</span>
</CommandItem>
<CommandItem>
<Smile />
<span>Search Emoji</span>
</CommandItem>
<CommandItem disabled>
<Calculator />
<span>Calculator</span>
</CommandItem>
</CommandGroup>
<CommandSeparator />
<CommandGroup heading='Settings'>
<CommandItem>
<User />
<span>Profile</span>
<CommandShortcut>⌘P</CommandShortcut>
</CommandItem>
<CommandItem>
<CreditCard />
<span>Billing</span>
<CommandShortcut>⌘B</CommandShortcut>
</CommandItem>
<CommandItem>
<Settings />
<span>Settings</span>
<CommandShortcut>⌘S</CommandShortcut>
</CommandItem>
</CommandGroup>
</CommandList>
</Command>
</>
)
}
export default BasicCommandCode
Dialog Command
Please press CTRL + J to show command dialog
Press⌘J
No results found.
Search Emoji
Calculator
Profile⌘P
Billing⌘B
Settings⌘S
Component Code
Copy Code
import React from 'react'
import {
Calculator,
Calendar,
CreditCard,
Settings,
Smile,
User,
} from 'lucide-react'
import {
Command,
CommandDialog,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
CommandShortcut,
} from '@/components/ui/command'
import { DialogTitle } from '@/components/ui/dialog'
const DialogCommandCode = () => {
const [open, setOpen] = React.useState(false)
React.useEffect(() => {
const down = (e: KeyboardEvent) => {
if (e.key === 'j' && (e.metaKey || e.ctrlKey)) {
e.preventDefault()
setOpen((open) => !open)
}
}
document.addEventListener('keydown', down)
return () => document.removeEventListener('keydown', down)
}, [])
return (
<>
<p className='text-sm text-ld flex gap-2 mt-4'>
Press
<kbd className='pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded bg-lightprimary dark:bg-dark p-1.5 font-mono text-[10px] font-medium text-ld opacity-100'>
<span className='text-xs'>⌘</span>J
</kbd>
</p>
<Command className='rounded-lg border border-ld dark:border-gray-600 mt-4'>
<CommandInput
className='border-none'
placeholder='Type a command or search...'
/>
<CommandList>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup heading='Settings'>
<CommandItem>
<Smile />
<span>Search Emoji</span>
</CommandItem>
<CommandItem disabled>
<Calculator />
<span>Calculator</span>
</CommandItem>
<CommandItem>
<User />
<span>Profile</span>
<CommandShortcut>⌘P</CommandShortcut>
</CommandItem>
<CommandItem>
<CreditCard />
<span>Billing</span>
<CommandShortcut>⌘B</CommandShortcut>
</CommandItem>
<CommandItem>
<Settings />
<span>Settings</span>
<CommandShortcut>⌘S</CommandShortcut>
</CommandItem>
</CommandGroup>
</CommandList>
</Command>
<CommandDialog open={open} onOpenChange={setOpen}>
<DialogTitle className='sr-only'>Command Dialog</DialogTitle>{' '}
{/* Visually hidden */}
<CommandInput placeholder='Type a command or search...' />
<CommandList>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup heading='Suggestions'>
<CommandItem>
<Calendar />
<span>Calendar</span>
</CommandItem>
<CommandItem>
<Smile />
<span>Search Emoji</span>
</CommandItem>
<CommandItem>
<Calculator />
<span>Calculator</span>
</CommandItem>
</CommandGroup>
<CommandSeparator />
<CommandGroup heading='Settings'>
<CommandItem>
<User />
<span>Profile</span>
<CommandShortcut>⌘P</CommandShortcut>
</CommandItem>
<CommandItem>
<CreditCard />
<span>Billing</span>
<CommandShortcut>⌘B</CommandShortcut>
</CommandItem>
<CommandItem>
<Settings />
<span>Settings</span>
<CommandShortcut>⌘S</CommandShortcut>
</CommandItem>
</CommandGroup>
</CommandList>
</CommandDialog>
</>
)
}
export default DialogCommandCode