import { Checkbox } from 'sud-ui';여러 옵션 중 하나 이상을 선택할 때
사용자의 선택이나 결정을 확인할 때
import React, { useState } from "react";
import { Checkbox } from "sud-ui";
export default function Example() {
return <Checkbox>Checkbox</Checkbox>;
}import React, { useState } from "react";
import { Checkbox } from "sud-ui";
export default function Example() {
return (
<div className="flex flex-col gap-[10px]">
<Checkbox defaultChecked>Default Checked Checkbox</Checkbox>
<Checkbox>Unchecked Checkbox</Checkbox>
</div>
);
}import React, { useState } from "react";
import { Checkbox } from "sud-ui";
export default function Example() {
const [value, setValue] = useState(null);
const options1 = [
{
label: "label 1",
value: "checkbox1"
},
{
label: "label 2",
value: "checkbox2"
},
{
label: "label 3",
value: "checkbox3"
}
];
const options2 = [
{
label: "label 1",
value: "checkbox1"
},
{
label: "label 2",
value: "checkbox2"
},
{
label: "label 3",
value: "checkbox3",
disabled: true
}
];
return (
<div className="flex flex-col gap-[10px]">
<Checkbox.Group
options={options1}
direction="horizontal"
value={value}
onChange={setValue}
itemDisabled={["Checkbox2"]}
layout="grid"
cols={3}
/>
<Checkbox.Group
options={options2}
direction="horizontal"
value={value}
onChange={setValue}
layout="grid"
cols={3}
/>
</div>
);
}import React from "react";
import { Checkbox } from "sud-ui";
export default function Example() {
return (
<div className="flex flex-col gap-[10px]">
<Checkbox colorType="primary" checked>
Primary Checkbox
</Checkbox>
<Checkbox colorType="success" checked>
Success Checkbox
</Checkbox>
<Checkbox colorType="warning" checked>
Warning Checkbox
</Checkbox>
<Checkbox colorType="danger" checked>
Danger Checkbox
</Checkbox>
<Checkbox colorType="info" checked>
Info Checkbox
</Checkbox>
</div>
);
}import React from "react";
import { Checkbox } from "sud-ui";
export default function Example() {
return <Checkbox disabled>Disabled Checkbox</Checkbox>;
}import React, { useState } from "react";
import { Checkbox, Avatar } from "sud-ui";
export default function Example() {
const [value, setValue] = useState(null);
const options = [
{
label: <Avatar />,
value: "Checkbox1"
},
{
label: <Avatar sample={2} />,
value: "Checkbox2"
},
{
label: <Avatar sample={3} />,
value: "Checkbox3"
},
{
label: <Avatar sample={4} />,
value: "Checkbox4"
},
{
label: <Avatar sample={5} />,
value: "Checkbox5"
}
];
return (
<div>
<Checkbox.Group
options={options}
direction="horizontal"
labelPosition="top"
value={value}
onChange={setValue}
/>
</div>
);
}import React from "react";
import { Checkbox } from "sud-ui";
export default function Example() {
return (
<div className="flex flex-row gap-[20px] flex-wrap">
<Checkbox labelPosition="left" defaultChecked>
left
</Checkbox>
<Checkbox labelPosition="right" defaultChecked>
right
</Checkbox>
<Checkbox labelPosition="top" defaultChecked>
top
</Checkbox>
<Checkbox labelPosition="bottom" defaultChecked>
bottom
</Checkbox>
</div>
);
}속성 이름 | 설명 | 타입 | 기본값 |
|---|
| checked | 체크박스의 선택 상태 (제어 컴포넌트) | boolean | - |
| defaultChecked | 체크박스의 초기 선택 상태 (비제어 컴포넌트) | boolean | false |
| children | 체크박스 라벨 | ReactNode | - |
| name | 폼 제출에 사용할 이름 | string | - |
| value | 폼 제출에 사용할 값 | string | number | - |
| required | 필수 입력 여부 | boolean | false |
| onChange | 선택 상태가 변경될 때 호출되는 함수 (checked: boolean) => void | (checked: boolean) => void | - |
| labelPosition | 라벨의 위치 | left | right | top | bottom | right |
| color | 체크박스의 색상(palette값 또는 HEX code) | string | - |
| disabled | 비활성화 여부 | boolean | false |
| colorType | 체크박스의 색상 타입 | default | primary | success | warning | danger | info | red | rose | coral | orange | volcano | apricot | yellow | gold | amber | green | lime | mint | blue | sky | cerulean | indigo | cobalt | navy | purple | plum | orchid | forest | sage | warm-gray | cool-gray | neutral | text | ghost | primary |
| className | 추가 클래스명 | string | "" |
| style | 추가 스타일 | CSSProperties | {} |
| ariaLabel | ARIA 라벨 | string | - |
| ariaRequired | ARIA required 속성 | boolean | - |
| ariaInvalid | ARIA invalid 속성 | boolean | - |
| ariaDescribedby | ARIA describedby 속성 | string | - |
속성 이름 | 설명 | 타입 | 기본값 |
|---|
| options | 체크박스 그룹의 옵션 배열 | Array<{label: ReactNode, value: string | number, disabled?: boolean}> | [] |
| value | 선택된 값들의 배열 | (string | number)[] | [] |
| onChange | 선택 상태가 변경될 때 호출되는 함수 (values: (string | number)[]) => void | (values: (string | number)[]) => void | - |
| layout | 레이아웃 타입 | flex | grid | flex |
| direction | 배치 방향 | horizontal | vertical | vertical |
| cols | 그리드 레이아웃의 열 수 | number | 1 |
| gap | 체크박스 간의 간격 | number | 8 |
| disabled | 전체 그룹 비활성화 여부 | boolean | false |
| itemDisabled | 비활성화할 체크박스 값들의 배열 | (string | number)[] | [] |
| color | 체크박스의 색상(palette값 또는 HEX code) | string | - |
| colorType | 체크박스의 색상 타입 | default | primary | success | warning | danger | info | red | rose | coral | orange | volcano | apricot | yellow | gold | amber | green | lime | mint | blue | sky | cerulean | indigo | cobalt | navy | purple | plum | orchid | forest | sage | warm-gray | cool-gray | neutral | text | ghost | primary |
| labelPosition | 라벨의 위치 | left | right | top | bottom | right |
| ariaLabel | ARIA 라벨 | string | - |
| ariaRequired | ARIA required 속성 | boolean | - |
| name | 체크박스 그룹의 이름 | string | - |
| role | ARIA role | string | group |
| className | 추가 클래스명 | string | "" |
| style | 추가 스타일 | CSSProperties | {} |