Radio

Radio

Radio 컴포넌트는 사용자가 그룹에서 하나의 옵션을 선택할 수 있게 합니다.

예제

Default Use RadioGroup with an options array to create a group of radio buttons. Only one option can be selected at a time.

코드 보기
1import { RadioGroup } from '@devup-ui/components'
2
3export default function Default() {
4    return (
5        <RadioGroup
6            defaultValue="option1"
7            options={[
8                { value: 'option1', label: 'Option 1' },
9                { value: 'option2', label: 'Option 2' },
10                { value: 'option3', label: 'Option 3' },
11            ]}
12        />
13    )
14}
15
1import { RadioGroup } from '@devup-ui/components'
2
3export default function Default() {
4    return (
5        <RadioGroup
6            defaultValue="option1"
7            options={[
8                { value: 'option1', label: 'Option 1' },
9                { value: 'option2', label: 'Option 2' },
10                { value: 'option3', label: 'Option 3' },
11            ]}
12        />
13    )
14}
15

Variant Use variant="button" to display radio options as a segmented button group. Options are displayed inline with connected borders.

코드 보기
1import { RadioGroup } from '@devup-ui/components'
2
3export default function ButtonVariant() {
4    return (
5        <RadioGroup
6            defaultValue="option1"
7            options={[
8                { value: 'option1', label: 'Option 1' },
9                { value: 'option2', label: 'Option 2' },
10                { value: 'option3', label: 'Option 3' },
11            ]}
12            variant="button"
13        />
14    )
15}
16
1import { RadioGroup } from '@devup-ui/components'
2
3export default function ButtonVariant() {
4    return (
5        <RadioGroup
6            defaultValue="option1"
7            options={[
8                { value: 'option1', label: 'Option 1' },
9                { value: 'option2', label: 'Option 2' },
10                { value: 'option3', label: 'Option 3' },
11            ]}
12            variant="button"
13        />
14    )
15}
16

Direction Use direction="column" to stack radio buttons vertically. Default direction is "row" which displays options horizontally.

코드 보기
1import { RadioGroup } from '@devup-ui/components'
2
3export default function Column() {
4    return (
5        <RadioGroup
6            defaultValue="option1"
7            direction="column"
8            options={[
9                { value: 'option1', label: 'Option 1' },
10                { value: 'option2', label: 'Option 2' },
11                { value: 'option3', label: 'Option 3' },
12            ]}
13        />
14    )
15}
16
1import { RadioGroup } from '@devup-ui/components'
2
3export default function Column() {
4    return (
5        <RadioGroup
6            defaultValue="option1"
7            direction="column"
8            options={[
9                { value: 'option1', label: 'Option 1' },
10                { value: 'option2', label: 'Option 2' },
11                { value: 'option3', label: 'Option 3' },
12            ]}
13        />
14    )
15}
16

Disabled Use disabled prop to prevent user interaction with all radio options. All radios will have a muted appearance and cannot be selected.

코드 보기
1import { RadioGroup } from '@devup-ui/components'
2
3export default function Disabled() {
4    return (
5        <RadioGroup
6            defaultValue="option1"
7            disabled
8            options={[
9                { value: 'option1', label: 'Option 1' },
10                { value: 'option2', label: 'Option 2' },
11                { value: 'option3', label: 'Option 3' },
12            ]}
13        />
14    )
15}
16
1import { RadioGroup } from '@devup-ui/components'
2
3export default function Disabled() {
4    return (
5        <RadioGroup
6            defaultValue="option1"
7            disabled
8            options={[
9                { value: 'option1', label: 'Option 1' },
10                { value: 'option2', label: 'Option 2' },
11                { value: 'option3', label: 'Option 3' },
12            ]}
13        />
14    )
15}
16
API

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

속성설명타입기본값
children

라디오의 레이블 내용

React.ReactNode

undefined

checked

라디오의 선택 여부

boolean

undefined

disabled

라디오의 비활성화 여부

boolean

false

variant

라디오의 시각적 variant

'default' | 'button'

'default'

firstButton

버튼 그룹의 첫 번째 버튼인지 여부(button variant 전용)

boolean

undefined

lastButton

버튼 그룹의 마지막 버튼인지 여부(button variant 전용)

boolean

undefined

classNames

내부 요소에 적용할 사용자 정의 클래스 이름

{
label?: string

}

undefined

styles

내부 요소에 적용할 사용자 정의 인라인 스타일

{
label?: React.CSSProperties

}

undefined

colors

라디오의 사용자 정의 색상 변수

{
primary?: string

border?: string

text?: string

bg?: string

hoverBg?: string

hoverBorder?: string

hoverColor?: string

checkedBg?: string

checkedBorder?: string

checkedColor?: string

disabledBg?: string

disabledColor?: string

}

undefined

RadioGroup API

RadioGroup은 라디오 버튼 그룹을 관리하는 컴포넌트입니다.

속성설명타입기본값
options

라디오 그룹의 옵션 배열

{ value: string | number | boolean; label: React.ReactNode }[]

value

라디오 그룹의 제어 값

string | number | boolean

undefined

defaultValue

라디오 그룹의 기본값(비제어)

string | number | boolean

undefined

onChange

선택한 값이 바뀔 때 호출되는 콜백

(value: string | number | boolean) => void

undefined

disabled

그룹 안 모든 라디오의 비활성화 여부

boolean

false

direction

라디오 그룹의 배치 방향

'row' | 'column'

'row'

variant

라디오 버튼의 시각적 variant

'default' | 'button'

'default'

colors

사용자 정의 색상 변수(Radio의 colors와 동일)

RadioColors

undefined

classNames

내부 요소에 적용할 사용자 정의 클래스 이름

{
label?: string

container?: string

}

undefined

styles

내부 요소에 적용할 사용자 정의 인라인 스타일

{
label?: React.CSSProperties

container?: React.CSSProperties

}

undefined