# Radio

Radios let users choose a single option from a list.

## Demo

{% demo 'A radio', 'edsRadioDemo', demos.edsRadioDemo, component.brand %}

## When to use this component

Use the Radio component when users need to select only 1 option from a list of choices.

## When not to use this component

Do not use the Radio component if users may need to choose more than 1 option.

## How it works

Use the [fieldset component](https://elements.springernature.com/components/springernature/eds-c-fieldset/) to group radios together and give the group a label using the `legend` element.

Place radios to the left of their label. This makes them easier to find, especially for screen magnification users.

Do not assume that users will know that they can only choose 1 option. Consider using hint text, such as 'Select 1 option'.

Do not pre-select an option for the user, even if you think it is the most common answer. This could lead to them submitting an incorrect answer or not realising they have missed the question.

### Installation

To install the components, [go to the get started guide for developers](https://github.com/springernature/elements).

To use the Radio component, enter the following command in your Terminal: 

```bash
npm install @springernature/elements
```

### Styles

First, import the styles of the Form component:

```scss
@import '../path/to/@springernature/elements/components/eds-c-form';
```

Then, import the styles of the Fieldset component into your `scss` file:

```scss
@import '../path/to/@springernature/elements/components/eds-c-fieldset';
```

Finally, import the styles of the Radio component into your `scss` file:

```scss
@import '../path/to/@springernature/elements/components/eds-c-radio';
```

### Configuration

#### Properties

For more detailed information on how to use the properties correctly, [go to the radio schema file](https://github.com/springernature/elements/blob/main/components/eds-c-radio/data/eds-c-radio.schema.json).

Pass this property to the label object:

```json
"cssClass": "eds-c-radio__label"
```

For more information on the label object, [go to the label schema file](https://github.com/springernature/elements/blob/main/components/eds-c-label/data/eds-c-label.schema.json).

### Templates

Use the Radio component with the [Form component](https://elements.springernature.com/components/springernature/eds-c-form/).

Use the [form template](https://github.com/springernature/elements/blob/main/components/eds-c-form/eds-c-form.hbs) and read the [schema file](https://github.com/springernature/elements/blob/main/components/eds-c-form/data/eds-c-form.schema.json).

You can pass the Radio component in the inputs array as many times as you need.
