A radio group allows a user to select a single item from a list of mutually exclusive options.
This component is built on top of react-aria-components's RadioGroup. You can refer to the official documentation for more details on the base API.
import { Radio, RadioGroup } from "@opengovsg/oui"<RadioGroup label="Select a city" defaultValue="sf">
<Radio value="sf">San Francisco</Radio>
<Radio value="ny">New York</Radio>
</RadioGroup>Use the size prop on RadioGroup to change the size of all radio items within the group. The size is propagated to all children via context.
Use the description prop on individual Radio items to add helper text below the label.
Use the isDisabled prop on RadioGroup to disable the entire group, or on individual Radio items to disable specific options.
Use the isInvalid prop along with errorMessage to display a validation error.
You can customize the Radio and RadioGroup components by passing custom Tailwind CSS classes to the component slots via the classNames prop.