import { Radio } from 'sud-ui';여러 옵션 중 하나를 선택할 때
사용자의 선택이나 결정을 확인할 때
import React, { useState } from "react";
import { Radio } from "sud-ui";
export default function Example() {
return (
<div>
<Radio>Radio</Radio>
</div>
);
}import React, { useState } from "react";
import { Radio } from "sud-ui";
export default function Example() {
return (
<div>
<Radio defaultChecked>Default Checked Radio</Radio>
</div>
);
}import React, { useState } from "react";
import { Radio } from "sud-ui";
export default function Example() {
const [value, setValue] = useState(null);
const options1 = [
{
label: "label 1",
value: "radio1"
},
{
label: "disable option",
value: "radio2"
},
{
label: "label 3",
value: "radio3"
}
];
const options2 = [
{
label: "label 1",
value: "radio1"
},
{
label: "disable option",
value: "radio2"
},
{
label: "label 3",
value: "radio3",
disabled: true
}
];
return (
<div className="flex flex-col gap-[10px]">
<Radio.Group
options={options1}
direction="horizontal"
value={value}
onChange={setValue}
itemDisabled={["radio2"]}
layout="grid"
cols={3}
/>
<Radio.Group
options={options2}
direction="horizontal"
value={value}
onChange={setValue}
layout="grid"
cols={3}
/>
</div>
);
}import React from "react";
import { Radio } from "sud-ui";
export default function Example() {
return (
<div>
<Radio disabled>Disabled Radio</Radio>
</div>
);
}import React, { useState } from "react";
import { Radio, Avatar } from "sud-ui";
export default function Example() {
const [value, setValue] = useState(null);
const options = [
{
label: <Avatar />,
value: "radio1"
},
{
label: <Avatar sample={2} />,
value: "radio2"
},
{
label: <Avatar sample={3} />,
value: "radio3"
},
{
label: <Avatar sample={4} />,
value: "radio4"
},
{
label: <Avatar sample={5} />,
value: "radio5"
}
];
return (
<div>
<Radio.Group
options={options}
direction="horizontal"
labelPosition="top"
value={value}
onChange={setValue}
/>
</div>
);
}import React from "react";
import { Radio } from "sud-ui";
export default function Example() {
return (
<div className="flex flex-col gap-[10px]">
<Radio colorType="primary" checked>
Primary Radio
</Radio>
<Radio colorType="secondary" checked>
Secondary Radio
</Radio>
<Radio colorType="success" checked>
Success Radio
</Radio>
<Radio colorType="warning" checked>
Warning Radio
</Radio>
<Radio colorType="danger" checked>
Danger Radio
</Radio>
<Radio colorType="info" checked>
Info Radio
</Radio>
</div>
);
}속성 이름 | 설명 | 타입 | 기본값 |
|---|
| checked | 라디오 버튼의 선택 상태 (제어 컴포넌트) | boolean | - |
| defaultChecked | 라디오 버튼의 초기 선택 상태 (비제어 컴포넌트) | boolean | false |
| onChange | 선택 상태가 변경될 때 호출되는 함수 | (checked: boolean) => void | - |
| labelPosition | 라벨의 위치 | left | right | top | bottom | right |
| children | 라디오 버튼의 라벨 | ReactNode | - |
| 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 | - |
| name | 라디오 버튼의 이름 | string | - |
| value | 폼 제출에 사용할 값 | string | number | - |
| required | 필수 입력 여부 | boolean | false |
속성 이름 | 설명 | 타입 | 기본값 |
|---|
| options | 라디오 버튼 옵션 배열 | Array<{ label: ReactNode, value: string | number, disabled?: boolean }> | [] |
| value | 현재 선택된 값 | string | number | null | - |
| onChange | 값이 변경될 때 호출되는 함수 | (value: 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 | - |
| className | 추가 클래스명 | string | - |
| style | 추가 스타일 | CSSProperties | {} |