Radio
A radio button for choosing one option from several. Used within a radio group.
View in Storybook (opens in a new tab)
Installation
import { Radio } from "@ginga-ui/core";Basic usage
A simple radio group example.
radio.tsx
import { Radio, RadioGroup } from "@ginga-ui/core";
export function BasicExample() {
return (
<RadioGroup>
<Radio value="option1">Option 1</Radio>
<Radio value="option2">Option 2</Radio>
<Radio value="option3">Option 3</Radio>
</RadioGroup>
);
}Default value
A radio group with an initially selected value.
radio.tsx
import { Radio, RadioGroup } from "@ginga-ui/core";
export function DefaultValueExample() {
return (
<RadioGroup defaultValue="option2">
<Radio value="option1">Option 1</Radio>
<Radio value="option2">Option 2 (selected by default)</Radio>
<Radio value="option3">Option 3</Radio>
</RadioGroup>
);
}Disabled
A radio group with some options disabled.
radio.tsx
import { Radio, RadioGroup } from "@ginga-ui/core";
export function DisabledExample() {
return (
<RadioGroup>
<Radio value="option1">Option 1</Radio>
<Radio value="option2" disabled>
Option 2 (disabled)
</Radio>
<Radio value="option3">Option 3</Radio>
</RadioGroup>
);
}Controlled radio group
A radio group whose state is controlled externally.
radio.tsx
import { Radio, RadioGroup } from "@ginga-ui/core";
export function ControlledExample() {
return (
<RadioGroup onChange={(value) => console.log("Selected:", value)}>
<Radio value="small">Small</Radio>
<Radio value="medium">Medium</Radio>
<Radio value="large">Large</Radio>
</RadioGroup>
);
}Props
RadioGroup
| Name | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | Disables every radio button in the group. |
required | boolean | false | Requires a selection. |
readOnly | boolean | false | Prevents the user from changing the selection. |
invalid | boolean | false | Shows the group as invalid. |
Also accepts the props of React Aria's RadioGroup (opens in a new tab).
Radio
| Name | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | Disables the radio button. |
Also accepts the props of React Aria's Radio (opens in a new tab).