Skip to main content
HomeFormRadio
warning
This is a beta release of the Quantum web libraries
Please be careful when using them in production, as they may contain bugs, unstable breaking changes, and incomplete features.

Radio

Radio buttons are used when you have a group of mutually exclusive choices and only one selection from the group is allowed.

Sizes

Radios are available in three sizes to cater for the diverse range of use cases and devices that our business uses. By default, the medium radio is used.

Small

Medium

Large

<QtmRadioButton name="size" size="small" checked>Small</QtmRadioButton>
<QtmRadioButton name="size" size="medium">Medium</QtmRadioButton>
<QtmRadioButton name="size" size="large">Large</QtmRadioButton>

Selection

Radios can be checked by adding checked attribute.

Small

Medium

Large

<QtmRadioButton size="small" checked>Small</QtmRadioButton>
<QtmRadioButton size="medium" checked>Medium</QtmRadioButton>
<QtmRadioButton size="large" checked>Large</QtmRadioButton>

Colors

Radios are available in two colors: primary and neutral. The default color is the primary color.

Primary Checked

Primary Unchecked

Neutral Checked

Neutral Unchecked

<QtmRadioButton name="primary" color="primary" checked>Primary Checked</QtmRadioButton>
<QtmRadioButton name="neutral" color="neutral" checked>Primary Checked</QtmRadioButton>
// ...

Errors

Radios can also have an error state to show that a selection needs to be made in order to move forward, or that a selection that was made is invalid.

Primary Checked

Primary Unchecked

Neutral Checked

Neutral Unchecked

<QtmRadioButton name="primary-error" checked error>Primary Checked</QtmRadioButton>
// ...

Disabled

Radios can also have a disabled state.

Primary Checked

Primary Unchecked

Neutral Checked

Neutral Unchecked

<QtmRadioButton name="primary-disabled" checked disabled>Primary Checked</QtmRadioButton>
// ...

Value

You can set value for a radio button by using value attribute.

<QtmRadioButton value="small">Small</QtmRadioButton>

Name

You can set name for a radio button by using name attribute.

<QtmRadioButton name="Radio-Button">Radio Button</QtmRadioButton>

Label

You can set label for a radio button by using label attribute. When label attribute is set, the text of the button is set to the same.

<QtmRadioButton label="Radio Button" checked></QtmRadioButton>

Required

If a radio button has the attribute required, it has to be checked.

<QtmRadioButton required>Radio Button</QtmRadioButton>

InputId

The id of the radio element

<QtmRadioButton inputId="radio-button">Radio Button</QtmRadioButton>

Custom labels

Radios accepts any component as its label. Make sure to use items with clear textual labels, or elements that are self explanatory in the given context.

Option 1

This is some placeholder help text.

<QtmRadioButton checked>
<div>
<QtmTypography>Option 1</QtmTypography>
<QtmTypography component="caption-1" classes="text-bluegrey-500">
This is some placeholder help text.
</QtmTypography>
</div>
</QtmRadioButton>

Radio Group

QtmRadioGroup is a helpful wrapper used to group radio elements. Make sure that QtmRadioGroup component has a name attribute.

Radio 1Radio 2Radio 3
<QtmRadioGroup name="radioGroup1">
<QtmRadioButton checked>Radio 1</QtmRadioButton>
<QtmRadioButton>Radio 2</QtmRadioButton>
<QtmRadioButton>Radio 3</QtmRadioButton>
</QtmRadioGroup>

Sizes

QtmRadioGroup are available in three sizes that correspond to the different bottom margin values and size of their child elements. By default, the medium size is used.

SmallRadio 1Radio 2Radio 3MediumRadio 1Radio 2Radio 3LargeRadio 1Radio 2Radio 3
<QtmRadioGroup size="small" name="radioGroupSizeSmall">
<QtmRadioButton checked>Radio 1</QtmRadioButton>
<QtmRadioButton>Radio 2</QtmRadioButton>
<QtmRadioButton>Radio 3</QtmRadioButton>
</QtmRadioGroup>
// ...

Value

You can set a default value for a radio button group by using defaultValue attribute. And you can also control value of this group by using value attribute

Radio 1Radio 2Radio 3
<QtmRadioGroup defaultValue="radio1" name="radioGroup">
<QtmRadioButton value="radio1">Radio 1</QtmRadioButton>
<QtmRadioButton value="radio2">Radio 2</QtmRadioButton>
<QtmRadioButton value="radio3">Radio 3</QtmRadioButton>
</QtmRadioGroup>

API

Radio

Loading API documentation...

RadioGroup

Loading API documentation...

Spotted a bug, have a question, or want to suggest a new feature?

Submit an issue on GitLab