Checkbox
체크박스 컨트롤. 클릭으로 선택/해제할 수 있으며, 3단계 순환 모드를 지원한다.
개요
CALS Checkbox는 Foundation Checkbox를 래핑하여 CALS 전용 기능(토큰 오버라이드, FormItem 래핑, 3단계 순환 등)을 제공한다.
주요 특징
- ✅ 기본 선택/해제: 클릭으로 체크 토글
- ✅ 3단계 순환: threeState 모드에서 unchecked→checked→indeterminate 순환
- ✅ 읽기 전용: 상태 표시만 하고 조작 차단
- ✅ 디자인 토큰: Foundation 토큰 시스템 완벽 호환
- ✅ FormItem 래핑: label/required/error 자동 래핑
기본 사용
children으로 라벨 텍스트를 전달한다.
Preview
크기
size prop으로 체크박스 크기를 변경한다.
Preview
비활성 상태
disabled prop으로 클릭을 차단한다.
Preview
읽기 전용
readOnly prop은 클릭을 차단하지만 기존 상태를 유지한다.
Preview
3단계 체크박스
threeState prop으로 unchecked→checked→indeterminate 순환을 활성화한다.
Preview
FormItem 래핑
label, required, description, error prop을 제공하면 FormItem으로 자동 래핑된다.
Preview
필수 선택 항목입니다
커스텀 색상
backgroundColor, color, borderColor prop으로 토큰을 오버라이드한다.
Preview
API Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
checked | boolean | "indeterminate" | - | 체크 상태 (제어 모드) |
defaultChecked | boolean | "indeterminate" | - | 초기 체크 상태 (비제어 모드) |
threeState | boolean | false | 3단계 순환 활성화 |
size | "xs" | "sm" | "md" | "lg" | "xl" | "md" | 체크박스 크기 |
visible | boolean | true | 표시 여부 |
disabled | boolean | - | 비활성화 |
readOnly | boolean | - | 읽기 전용 |
title | string | - | HTML title 속성 (네이티브 툴팁) |
backgroundColor | string | - | 배경색 + 파생 색상 |
color | string | - | 라벨 텍스트 색상 |
borderColor | string | - | 테두리 색상 + 파생 색상 |
fontSize | string | - | 라벨 폰트 크기 |
fontWeight | string | number | - | 라벨 폰트 굵기 |
fontStyle | string | - | 라벨 폰트 스타일 |
showLabel | boolean | false | 빈 레이블 공간 표시 |
className | string | - | 컨테이너에 적용할 CSS 클래스 |
formClassName | string | - | FormItem 래퍼에 적용할 CSS 클래스 |
style | CSSProperties | - | 인라인 스타일 |
children | ReactNode | - | 라벨 콘텐츠 |
label | string | - | FormItem 레이블 |
required | boolean | - | FormItem 필수 표시 |
description | string | - | FormItem 설명 텍스트 |
error | string | - | FormItem 에러 메시지 |
Events
| Event | Type | Description |
|---|---|---|
onCheckedChange | (value: boolean | "indeterminate") => void | 체크 상태 변경 시 호출 |
Ref (CheckboxRef)
| 메서드/속성 | Type | Description |
|---|---|---|
focus() | () => void | 체크박스에 포커스 |
blur() | () => void | 포커스 해제 |
element | HTMLButtonElement | null | 내부 요소 참조 |
접근성
권장 사항
- ✅ 의미 있는 라벨 텍스트를 children으로 제공
- ✅ 라벨 없는 체크박스에는 aria-label 사용
- ✅ 그룹화된 체크박스는 fieldset/legend으로 감싸기
- ❌ 라벨 없이 체크박스만 사용하지 않기
관련 컴포넌트
- Foundation Checkbox: 기본 체크박스 컴포넌트
- RadioGroup: 단일 선택 라디오 그룹
- FormItem: 폼 래퍼
Last updated on