컴포넌트
Command
명령 팔레트(⌘K)와 검색 목록.
import { CalendarDays, FileText, Users } from 'lucide-react'
import { useState } from 'react'
import { Button } from '@zest/primitives/Button.js'
import { CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from '@zest/primitives/Command.js'
import { Kbd } from '@zest/primitives/Kbd.js'
export default function Demo() {
const [open, setOpen] = useState(false)
return (
<>
<Button variant="outline" onClick={() => setOpen(true)} rightIcon={<span className="flex gap-1"><Kbd>⌘</Kbd><Kbd>J</Kbd></span>}>명령 팔레트</Button>
<CommandDialog open={open} onOpenChange={setOpen} hotkey="j">
<CommandInput placeholder="메뉴·구성원 검색" />
<CommandList>
<CommandEmpty>결과가 없어요</CommandEmpty>
<CommandGroup heading="메뉴">
<CommandItem><Users />구성원 관리</CommandItem>
<CommandItem><CalendarDays />근태 현황</CommandItem>
<CommandItem><FileText />결재</CommandItem>
</CommandGroup>
</CommandList>
</CommandDialog>
</>
)
}설치
shadcn CLI 로 소스를 프로젝트에 가져와요. 테마·유틸·의존 부품이 함께 설치돼요.
npx shadcn@latest add @zest/command패키지로 쓰려면 @zest-im/ui 에서 가져와요. 설치 안내
사용법
import { CommandDialog } from '@/components/ui/command'위 미리보기의 「코드」 탭이 실제로 동작하는 예제예요.
API
| prop | 타입 | 설명 |
|---|---|---|
open | boolean | — |
onOpenChange | (open: boolean) => void | — |
hotkey? | string | 지정하면 ⌘/Ctrl + 이 키로 연다 |
title? | string | — |
children | ReactNode | — |
표에 없는 HTML·Radix 속성은 그대로 전달돼요.