Radio component allows users to select a single option from a group.
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}
151import { 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}
15Variant
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}
161import { 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}
16Direction
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}
161import { 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}
16Disabled
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}
161import { 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}
16Radio props extends the input HTML attributes (except type).
| Prop | description | Type | Default |
|---|---|---|---|
| children | The label content of the radio |
|
|
| checked | Whether the radio is checked |
|
|
| disabled | Whether the radio is disabled |
|
|
| variant | The visual variant of the radio |
|
|
| firstButton | Whether this is the first button in a button group (only for button variant) |
|
|
| lastButton | Whether this is the last button in a button group (only for button variant) |
|
|
| classNames | Custom class names for inner elements |
|
|
| styles | Custom inline styles for inner elements |
|
|
| colors | Custom color variables for the radio |
|
|
RadioGroup component for managing a group of radio buttons.
| Prop | description | Type | Default |
|---|---|---|---|
| options | Array of options for the radio group |
| |
| value | The controlled value of the radio group |
|
|
| defaultValue | The default value of the radio group (uncontrolled) |
|
|
| onChange | Callback when the selected value changes |
|
|
| disabled | Whether all radios in the group are disabled |
|
|
| direction | The layout direction of the radio group |
|
|
| variant | The visual variant of the radio buttons |
|
|
| colors | Custom color variables (same as Radio colors) |
|
|
| classNames | Custom class names for inner elements |
|
|
| styles | Custom inline styles for inner elements |
|
|