---
title: "single-choice-radio"
description: "Select one option using radio controls."
permalink: /docs/runtime/all-ui-components/single-choice-radio/
---
# single-choice-radio

<RuntimeVersion updatedSince="4.75.0">
Refreshed the component's appearance and added the `disabled` attribute.
</RuntimeVersion>

## Overview

The `single-choice-radio` component allows users to make a single selection from a pre-defined set of options.

### Basic Example

**main.view\.xml**

```xml
<var name="animal_type" type="single-choice">
    <option key="carnivore">Carnivore</option>
    <option key="herbivore">Herbivore</option>
    <option key="omnivore">Omnivore</option>
</var>

<single-choice-radio label="Options" bind="animal_type" />
```

![](./media/spaces-2f9tchlr67elhbojpvhhud-2fuploads-2fgit-blob-a15e446cf9e9219e52baebd0f903a6657c834436-2fsingle-choice-radio-example-39fb53fe.png)

## Advanced Attributes

### `mode`

<SyntaxCard type={["row", "column"]} defaultValue="column" introduced="4.83.0" />

Configure the layout of the list of options. `row` lists options horizontally; `column` lists options vertically.

### `radio-position`

<SyntaxCard type={["left", "right"]} defaultValue="left" introduced="4.86.1" />

Specify where the radio button is positioned in the component (relative to the option label).

**main.view\.xml**

```xml
<columns>
    <column>
        <info>radio-position="left"</info>
        <single-choice-radio radio-position="left" bind="favorite_color_single" label="Favorite color" />
    </column>
    <column>
        <info>radio-position="right"</info>
        <single-choice-radio radio-position="right" bind="favorite_color_single" label="Favorite color" />
    </column>
</columns>
```

![](./media/spaces-2f9tchlr67elhbojpvhhud-2fuploads-2fpbsea5tcbd7nxzsxxhe7-2fimage-19320c1f.png)

### `align-content`

<AttributeReference label="align-content" href="/docs/runtime/common-component-attributes/align-content/" badge="advanced" tone="muted" />

### `align-label`

<AttributeReference label="align-label" href="/docs/runtime/common-component-attributes/align-label/" badge="advanced" tone="muted" />

### `disabled`

<AttributeReference label="disabled" href="/docs/runtime/common-component-attributes/disabled/" badge="advanced" tone="muted" />

### `id`

<AttributeReference label="id" href="/docs/runtime/common-component-attributes/id/" badge="advanced" tone="muted" />

### `label-case`

<AttributeReference label="label-case" href="/docs/runtime/common-component-attributes/label-case/" badge="advanced" tone="muted" />

### `label-color`

<AttributeReference label="label-color" href="/docs/runtime/common-component-attributes/label-color/" badge="advanced" tone="muted" />

### `on-change`

<Info>

When using `single-choice-integer` you can omit the key attribute on options. The value passed to the function assigned to `on-change` will correspond to the key starting from `0`.

</Info>

<AttributeReference label="on-change" href="/docs/runtime/common-component-attributes/on-change/" badge="advanced" tone="muted" />

### `show-if`

<AttributeReference label="show-if" href="/docs/runtime/common-component-attributes/show-if/" badge="advanced" tone="muted" />

### `hide-if`

<AttributeReference label="hide-if" href="/docs/runtime/common-component-attributes/hide-if/" badge="advanced" tone="muted" />

## Common Attributes

### `bind`

<AttributeReference label="bind" href="/docs/runtime/common-component-attributes/bind/" />

### `label`

<AttributeReference label="label" href="/docs/runtime/common-component-attributes/label/" />

### `required`

<AttributeReference label="required" href="/docs/runtime/common-component-attributes/required/" />

## Component Methods

The following component methods are available when an [`id`](/docs/runtime/common-component-attributes/id/) is assigned to the component and `component.singleChoiceRadio({id:'my-id'})` is called from JS/TS:

### `scrollIntoView`

Programmatically scroll until the `single-choice-radio` component is visible in the view.

### `selectItem`

Programmatically select an item by its label.

**main.view\.xml**

```xml
<var name="favorite_color" type="single-choice">
    <option key="green">Green</option>
    <option key="red">Red</option>
    <option key="yellow">Yellow</option>
</var>

<single-choice-radio id="my-radio" bind="favorite_color" label="Favorite Color" />

```

**main.js**

```javascript
function select() {
    component.singleChoiceRadio({id: 'my-radio'}).selectItem('Yellow');
}
```

### `selectItemByIndex`

Programmatically select an item by its index. **Note**: Indexes begin at 1.

**main.view\.xml**

```xml
<var name="favorite_color" type="single-choice">
    <option key="green">Green</option>
    <option key="red">Red</option>
    <option key="yellow">Yellow</option>
</var>

<single-choice-radio id="my-radio" bind="favorite_color" label="Favorite Color" />

```

**main.js**

```javascript
function select() {
    component.singleChoiceRadio({id: 'my-radio'}).selectItemByIndex(2);
    // Selects "Red"
}
```
