A radio group allows a user to select a single item from a list of mutually exclusive options.
import { RadioGroup } from '@backstage/ui';
<RadioGroup />| Prop | Type | Default | Responsive |
|---|---|---|---|
| size | smallmedium | small | Yes |
| label | string | - | No |
| icon | ReactNode | - | No |
| description | string | - | No |
| name | string | - | No |
| className | string | - | No |
| style | CSSProperties | - | No |
Here's a simple TextField with a description.
<RadioGroup
label="What is your favorite pokemon?"
orientation="horizontal"
>
<Radio value="bulbasaur">Bulbasaur</Radio>
<Radio value="charmander">Charmander</Radio>
<Radio value="squirtle">Squirtle</Radio>
</RadioGroup>You can disable the entire radio group by adding the isDisabled prop to the RadioGroup component.
<RadioGroup label="What is your favorite pokemon?" isDisabled>
<Radio value="bulbasaur">Bulbasaur</Radio>
<Radio value="charmander">Charmander</Radio>
<Radio value="squirtle">Squirtle</Radio>
</RadioGroup>You can disable a single radio by adding the isDisabled prop to the Radio component.
<RadioGroup label="What is your favorite pokemon?">
<Radio value="bulbasaur">Bulbasaur</Radio>
<Radio value="charmander" isDisabled>
Charmander
</Radio>
<Radio value="squirtle">Squirtle</Radio>
</RadioGroup>Here's an example of a radio group with errors.
<RadioGroup
label="What is your favorite pokemon?"
name="pokemon"
defaultValue="charmander"
validationBehavior="aria"
validate={value => (value === 'charmander' ? 'Nice try!' : null)}
>
<Radio value="bulbasaur">Bulbasaur</Radio>
<Radio value="charmander">Charmander</Radio>
<Radio value="squirtle">Squirtle</Radio>
</RadioGroup>You can make the radio group read only by adding the isReadOnly prop to the RadioGroup component.
<RadioGroup
label="What is your favorite pokemon?"
isReadOnly
defaultValue="charmander"
>
<Radio value="bulbasaur">Bulbasaur</Radio>
<Radio value="charmander">Charmander</Radio>
<Radio value="squirtle">Squirtle</Radio>
</RadioGroup>Our theming system is based on a mix between CSS classes, CSS variables and data attributes. If you want to customise this component, you can use one of these class names below.
bui-RadioGroupbui-RadioGroupContentbui-Radio0.6.0 - New RadioGroup + Radio component. #30327