컴포넌트
Field
라벨·안내·오류를 입력에 연결한다.
회사 이메일을 적어 주세요
숫자만 적어 주세요
import { Field } from '@zest/primitives/Field.js'
import { Input } from '@zest/primitives/Input.js'
export default function Demo() {
return (
<div className="flex w-full max-w-[360px] flex-col gap-4">
<Field label="이름" required><Input placeholder="홍길동" /></Field>
<Field label="이메일" hint="회사 이메일을 적어 주세요"><Input type="email" /></Field>
<Field label="연락처" error="숫자만 적어 주세요"><Input defaultValue="010-abcd" /></Field>
</div>
)
}설치
shadcn CLI 로 소스를 프로젝트에 가져와요. 테마·유틸·의존 부품이 함께 설치돼요.
npx shadcn@latest add @zest/field패키지로 쓰려면 @zest-im/ui 에서 가져와요. 설치 안내
사용법
import { Field } from '@/components/ui/field'위 미리보기의 「코드」 탭이 실제로 동작하는 예제예요.
API
| prop | 타입 | 설명 |
|---|---|---|
label | string | — |
hint? | string | — |
error? | string | — |
required? | boolean | — |
className? | string | — |
children | ReactElement<unknown, string | JSXElementConstructor<any>> | 입력 부품 1개. id·aria-describedby·aria-invalid 가 주입된다. |
표에 없는 HTML·Radix 속성은 그대로 전달돼요.
접근성
id·aria-describedby·aria-invalid 를 자동으로 주입.