Checkbox

Checkbox

Checkbox 컴포넌트는 사용자가 여러 옵션을 선택할 수 있게 합니다.

예제

Default Basic checkbox with a label. Users can click to toggle the checked state.

코드 보기
1import { Checkbox } from '@devup-ui/components'
2
3export default function Default() {
4    return <Checkbox>Agree to terms and conditions</Checkbox>
5}
6
1import { Checkbox } from '@devup-ui/components'
2
3export default function Default() {
4    return <Checkbox>Agree to terms and conditions</Checkbox>
5}
6

Checked Use defaultChecked prop to set the initial checked state for uncontrolled usage, or use checked prop for controlled state management.

코드 보기
1import { Checkbox } from '@devup-ui/components'
2
3export default function Checked() {
4    return <Checkbox defaultChecked>Checked by default</Checkbox>
5}
6
1import { Checkbox } from '@devup-ui/components'
2
3export default function Checked() {
4    return <Checkbox defaultChecked>Checked by default</Checkbox>
5}
6

Disabled Use disabled prop to prevent user interaction. The checkbox will have a muted appearance and cannot be toggled.

코드 보기
1import { Checkbox } from '@devup-ui/components'
2import { VStack } from '@devup-ui/react'
3
4export default function Disabled() {
5    return (
6        <VStack gap="8px">
7            <Checkbox disabled>Disabled unchecked</Checkbox>
8            <Checkbox defaultChecked disabled>
9                Disabled checked
10            </Checkbox>
11        </VStack>
12    )
13}
14
1import { Checkbox } from '@devup-ui/components'
2import { VStack } from '@devup-ui/react'
3
4export default function Disabled() {
5    return (
6        <VStack gap="8px">
7            <Checkbox disabled>Disabled unchecked</Checkbox>
8            <Checkbox defaultChecked disabled>
9                Disabled checked
10            </Checkbox>
11        </VStack>
12    )
13}
14

Colors Pass in an object containing color tokens into colors prop. You can customize the checkbox appearance using primary, border, text, inputBg, and checkIcon color values.

코드 보기
1import { Checkbox } from '@devup-ui/components'
2import { Flex } from '@devup-ui/react'
3
4export default function Colors() {
5    return (
6        <Flex flexWrap="wrap" gap="16px">
7            <Checkbox colors={{ primary: '#10B981' }} defaultChecked>
8                Green
9            </Checkbox>
10            <Checkbox colors={{ primary: 'orange' }} defaultChecked>
11                Orange
12            </Checkbox>
13            <Checkbox colors={{ primary: 'steelblue' }} defaultChecked>
14                Steel Blue
15            </Checkbox>
16        </Flex>
17    )
18}
19
1import { Checkbox } from '@devup-ui/components'
2import { Flex } from '@devup-ui/react'
3
4export default function Colors() {
5    return (
6        <Flex flexWrap="wrap" gap="16px">
7            <Checkbox colors={{ primary: '#10B981' }} defaultChecked>
8                Green
9            </Checkbox>
10            <Checkbox colors={{ primary: 'orange' }} defaultChecked>
11                Orange
12            </Checkbox>
13            <Checkbox colors={{ primary: 'steelblue' }} defaultChecked>
14                Steel Blue
15            </Checkbox>
16        </Flex>
17    )
18}
19
API

Checkbox props는 input HTML 속성(type, onChange 제외)을 확장합니다.

속성설명타입기본값
children

체크박스의 레이블 내용

React.ReactNode

checked

체크박스의 선택 여부(제어)

boolean

undefined

defaultChecked

체크박스의 기본 선택 여부(비제어)

boolean

false

disabled

체크박스의 비활성화 여부

boolean

false

onChange

선택 상태가 바뀔 때 호출되는 콜백

(checked: boolean) => void

undefined

colors

체크박스의 사용자 정의 색상 변수

{
primary?: string

border?: string

text?: string

inputBg?: string

checkIcon?: string

}

undefined