RadioGroup
Radios fill with an ink blob. A fieldset of real radio inputs.
Client componentWCAG AASince v0.1
Live example
import { RadioGroup, Radio } from "@plop-ui/react";
<RadioGroup legend="Priority" defaultValue="medium">
<Radio value="low">Low</Radio>
<Radio value="medium" dotColor="var(--plop-mustard)">Medium</Radio>
<Radio value="high" dotColor="var(--plop-tomato)">High, page everyone</Radio>
</RadioGroup>Change every prop live in the playground.
Props
RadioGroup
| Prop | Type | Default | What it does |
|---|---|---|---|
| childrenrequired | ReactNode | none | The Radio options. |
| legendrequired | ReactNode | none | The question, shown as the fieldset's legend. |
| className | string | none | Extra class on the fieldset. |
| defaultValue | string | none | Uncontrolled initial selected value. |
| disabled | boolean | false | Disables every option in the group. |
| name | string | a generated one | Form field name. |
| onValueChange | (value: string) => void | none | Called with the chosen option's value. |
| value | string | none | Controlled selected value. |
| vertical | boolean | true | Stack options vertically. |
Radio
| Prop | Type | Default | What it does |
|---|---|---|---|
| childrenrequired | ReactNode | none | The option's label. |
| valuerequired | string | none | The value the group reports when this option is chosen. |
| disabled | boolean | false | Disables just this option. |
| dotColor | string | ink | Color of the ink blob, as a CSS color or token variable. |
Use it well
DoUse it for 2 to 5 choices people should see all at once.
Don'tLeave a group with nothing selected when one answer is the sensible default.
Accessibility
- A <fieldset> and <legend> holding native radios.
- Arrow keys move between options, as with any radio group.