컴포넌트
Select
단일 선택.
import { useState } from 'react'
import { Field } from '@zest/primitives/Field.js'
import { Select } from '@zest/primitives/Select.js'
export default function Demo() {
const [v, setV] = useState<string>()
return (
<div className="w-full max-w-[260px]">
<Field label="고용형태"><Select value={v} onValueChange={setV} placeholder="선택" options={[{ value: 'full', label: '정규직' }, { value: 'contract', label: '계약직' }, { value: 'intern', label: '인턴' }, { value: 'part', label: '파트타임', disabled: true }]} /></Field>
</div>
)
}설치
shadcn CLI 로 소스를 프로젝트에 가져와요. 테마·유틸·의존 부품이 함께 설치돼요.
npx shadcn@latest add @zest/select패키지로 쓰려면 @zest-im/ui 에서 가져와요. 설치 안내
사용법
import { Select } from '@/components/ui/select'위 미리보기의 「코드」 탭이 실제로 동작하는 예제예요.
API
| prop | 타입 | 설명 |
|---|---|---|
value? | string | — |
onValueChange | (value: string) => void | — |
options | SelectOption[] | — |
placeholder? | string | — |
disabled? | boolean | — |
size? | "sm" | "md" | — |
id? | string | — |
className? | string | — |
aria-describedby? | string | — |
aria-invalid? | boolean | — |
aria-label? | string | — |
표에 없는 HTML·Radix 속성은 그대로 전달돼요.
접근성
↓/Enter 로 열고, 닫히면 트리거로 포커스가 돌아온다.