체크박스
체크박스 (Checkbox)
체크박스는 사용자가 여러 선택지 중에서 하나 이상의 옵션을 선택할 수 있게 하는 입력 컨트롤이에요.
출처: 문서
본문
Checkbox 컴포넌트
체크박스는 사용자가 여러 선택지 중에서 하나 이상의 옵션을 선택할 수 있게 하는 입력 컨트롤이에요.
- Keywords: checkbox, input, form, selection, choice, option, multiple
- Categories: forms-and-input
- Status: general-availability
예시
import Checkbox from '@atlaskit/checkbox/checkbox';
const Examples = (): React.JSX.Element => (
<>
<Checkbox label="Basic checkbox" />
<Checkbox label="Checked checkbox" isChecked />
</>
);
export default Examples;
Props
| Prop | Type | Description |
|---|---|---|
defaultChecked |
boolean |
Sets whether the checkbox begins as checked or unchecked |
id |
string |
The ID assigned to the input |
isChecked |
boolean |
Sets whether the checkbox is checked or unchecked |
isDisabled |
boolean |
Sets whether the checkbox is disabled |
isIndeterminate |
boolean |
Sets whether the checkbox is indeterminate |
isInvalid |
boolean |
Marks the field as invalid |
isRequired |
boolean |
Marks the field as required & changes the label style |
label |
string | number | ReactElement<any, string | JSXElementConstructor<any>> |
The label to be displayed to the right of the checkbox |
name |
string |
The name of the submitted field in a checkbox |
onChange |
(e: ChangeEvent<HTMLInputElement>, analyticsEvent: UIAnalyticsEvent) => void |
Function that is called whenever the state of the checkbox changes |
value |
string | number |
The value to be used in the checkbox input |
xcss |
false | (XCSSValue<"alignItems", DesignTokenStyles, ""> & {} & XCSSPseudo<"alignItems", never, never, DesignTokenStyles> & XCSSMediaQuery<...> & { ...; } & { ...; }) |
Bounded style API |
사용 지침
- 목록에서 여러 개를 선택하거나 명시적 확인(예: 설정)이 필요할 때 사용해요
- 그룹에서 일부만 선택됐을 때는 indeterminate 상태를 사용해요
- 관련된 체크박스를 논리적으로 그룹화해요
- 각 옵션에 명확한 라벨을 제공해요
- 기본 상태를 신중히 고려해요
- 단일 선택에는 Radio를, 컴팩트한 단일 선택에는 Dropdown을, 켜기/끄기에는 Toggle을 사용해요
콘텐츠 지침
- 짧고 설명적인 라벨을 작성하고 라벨 뒤에 문장 부호를 붙이지 마세요
- 관련 옵션 전체에 일관된 언어를 사용해요
- 가능하면 부정적인 표현을 피해요
- 관련 옵션을 함께 그룹화해요
접근성 지침
- 필수 또는 유효하지 않은 체크박스 상태에 대한 오류 메시지를 포함해요
- 컨트롤이 탭 순서에 있어야 한다면 disabled를 사용하지 마세요. 스크린 리더 사용자가 이유와 진행 방법을 들을 수 있도록 검증과 오류 메시지를 사용해요
- 모든 체크박스에 올바른 라벨링을 보장해요
- 선택지를 설명하는 명확하고 설명적인 라벨을 사용해요
- 키보드 탐색을 지원해요
- 필수 필드를 명확히 표시해요
- 적절한 오류 상태와 메시지를 사용해요