---
title: Radio
---

import LibraryInfo from '@theme/LibraryInfo'
import { Feedback, TokensTable, PropsTable } from '../../src/components'
import { Radio } from '@telus-uds/components-web'
import { Radio as BaseDocs } from 'docs/@telus-uds/components-base'
import AvailableOnBoth from '../../partials/_platform-considerations-both.mdx'
import NoStylisticVariants from '../../partials/_variants-none.mdx'

# Radio

<LibraryInfo figmaLink="https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2F4zJn2Qn6uXOqPP1GVDipy6%2F%25F0%259F%258D%2580-Allium-Components%3Fnode-id%3D458%253A458" />

```jsx live
<Radio label="This is a radio button" />
```

## Introduction

Radio component represents a radio button, either isolated or within a form.

[Follow the appropriate instructions](importing-components) to add this component in to your app.

## Guidance

:::caution
In most cases, **[RadioGroup](radio-group)** should be used instead of
using Radio directly.

Pass the `RadioGroup` an `items` array and it will render Radio buttons for each item in the array
with appropriate accessibility props, web form tags and state management.
:::

### Controlled version

If the radio button is controlled from outside, it needs to receive `checked` and `onChange` props.

For examples refer to [RadioGroup](radio-group).

### Uncontrolled version

In case of uncontrolled radio button you can use `defaultChecked` prop to provide the initial value.
Whenever the radio button gets toggled, it calls the `onChange` callback with the new value (boolean).

For examples refer to [RadioGroup](radio-group).

### Adding React elements in the Label

You also can use the `label` prop to pass a React element and display it accompanied by a text or not.
When including images as part of the label, please ensure that it is readable and it makes sense when announced by screen readers.

```jsx live
<Radio
  label={
    <div style={{ display: 'flex' }}>
      <Icon icon={Icons.Visa} /> ending in 7011
    </div>
  }
/>
```

### Using within forms

You can pass `name` and `value` props if you need a particular radio button to be a part of a radio group
on a form.

For examples refer to [RadioGroup](radio-group).

### Validation

You can mark a radio button as failing validation by setting the `error` prop to `true`.

For examples refer to [RadioGroup](radio-group).

### Accessibility

Radio component accepts all the common accessibility props, but also sets some defaults, including
accessibility role `radio` and accessibility state that depends on the other props (`checked`, `inactive`)
or the internal state in case of uncontrolled radio button.

### Platform considerations

<AvailableOnBoth />

## Props

- Use `label` prop to provide a label for the radio button. For a disabled `Radio` set the `inactive` prop to `true`.

<PropsTable base={BaseDocs} />

## Tokens

<TokensTable base={BaseDocs} component="Radio" />

## Variants

<NoStylisticVariants />

## Feedback

<Feedback component="Radio" />
