---
title: "React Forms Radio buttons Example | Mobiscroll"
component: "Forms"
framework: "React"
library_version: "6.1.5"
url: "https://demo.mobiscroll.com/react/forms/radio-button"
---

# Radio buttons - React Forms demo

React radio button demo for single select option lists. Use it with or without description, supports disabled styling. For React and Next.JS.

- [Live demo](https://demo.mobiscroll.com/react/forms/radio-button)
- [View React JS code on GitHub](https://github.com/acidb/mobiscroll-demos-react/tree/main/src/demos/form-components/forms/radio-button)
- [View React TS code on GitHub](https://github.com/acidb/mobiscroll-demos-react-ts/tree/main/src/demos/form-components/forms/radio-button)
- This demo in other frameworks: [JavaScript](https://demo.mobiscroll.com/javascript/forms/radio-button.md), [jQuery](https://demo.mobiscroll.com/jquery/forms/radio-button.md), [Angular](https://demo.mobiscroll.com/angular/forms/radio-button.md), [Vue](https://demo.mobiscroll.com/vue/forms/radio-button.md)

## Description

Set up radio-button lists for mutually exclusive value selection. Different color presets are available.

## What this demo shows

- This demo shows different examples for radio buttons.
- **Single selection** Radio button groups for selecting one option from a set of mutually exclusive choices.
- **Option content** Radio buttons with labels and optional descriptive text.
- **States** Selected, unselected, and disabled radio button states.
- **Color presets** Primary, secondary, success, danger, warning, and info radio button colors.
- **Selection indicator** A checkmark identifies the currently selected option.

## Best for

- **Settings and preferences** Choosing one value from a small set of configuration options.
- **Forms and questionnaires** Presenting mutually exclusive answers that remain visible for quick comparison.
- **Plans and service levels** Selecting one option when labels and supporting descriptions help explain the differences.
- **Availability constraints** Showing choices that are currently unavailable with a disabled state.
- **Status-based choices** Using color presets to distinguish options with different meanings or levels of importance.

## Tutorial

```html
<RadioGroup name="group">
    <Radio label="Radio Option 1" description="This is description for radio 1" defaultChecked={true} />
    <Radio label="Radio Option 2" description="This is description for radio 2" />
    <Radio label="Radio Option 3" />
    <Radio label="Disabled" disabled={true} />
</RadioGroup>
```

```html
<RadioGroup name="colors">
    <Radio label="Primary" color="primary" />
    <Radio label="Secondary" color="secondary" />
    <Radio label="Success" color="success" defaultChecked={true} />
    <Radio label="Danger" color="danger" />
    <Radio label="Warning" color="warning" />
    <Radio label="Info" color="info" />
</RadioGroup>
```

## Code

### JSX

```jsx
import { Page, Radio, RadioGroup, setOptions } from '@mobiscroll/react';

setOptions({
  theme: 'ios',
  themeVariant: 'light'
});

function App() {
  return (
    <Page>
      <div className="mbsc-form-group">
        <div className="mbsc-form-group-title">Radio buttons</div>
        <RadioGroup name="group">
          <Radio label="Radio Option 1" description="This is description for radio 1" defaultChecked={true} />
          <Radio label="Radio Option 2" description="This is description for radio 2" />
          <Radio label="Radio Option 3" />
          <Radio label="Disabled" disabled={true} />
        </RadioGroup>
      </div>
      <div className="mbsc-form-group">
        <div className="mbsc-form-group-title">Radio button colors</div>
        <RadioGroup name="colors">
          <Radio label="Primary" color="primary" />
          <Radio label="Secondary" color="secondary" />
          <Radio label="Success" color="success" defaultChecked={true} />
          <Radio label="Danger" color="danger" />
          <Radio label="Warning" color="warning" />
          <Radio label="Info" color="info" />
        </RadioGroup>
      </div>
    </Page>
  );
}

export default App;
```

### TSX

```tsx
import { Page, Radio, RadioGroup, setOptions } from '@mobiscroll/react';
import { FC } from 'react';

setOptions({
  theme: 'ios',
  themeVariant: 'light'
});

const App: FC = () => (
  <Page>
    <div className="mbsc-form-group">
      <div className="mbsc-form-group-title">Radio buttons</div>
      <RadioGroup name="group">
        <Radio label="Radio Option 1" description="This is description for radio 1" defaultChecked={true} />
        <Radio label="Radio Option 2" description="This is description for radio 2" />
        <Radio label="Radio Option 3" />
        <Radio label="Disabled" disabled={true} />
      </RadioGroup>
    </div>
    <div className="mbsc-form-group">
      <div className="mbsc-form-group-title">Radio button colors</div>
      <RadioGroup name="colors">
        <Radio label="Primary" color="primary" />
        <Radio label="Secondary" color="secondary" />
        <Radio label="Success" color="success" defaultChecked={true} />
        <Radio label="Danger" color="danger" />
        <Radio label="Warning" color="warning" />
        <Radio label="Info" color="info" />
      </RadioGroup>
    </div>
  </Page>
);
export default App;
```

## Implementation notes

- Radios are grouped with `RadioGroup`/`mbsc-radio-group` (JS/jQuery: a `div` carrying the `mbsc-radio-group` attribute); an individual option is `Radio`/`mbsc-radio`/`input[mbsc-radio][type="radio"]`.
- Mutual exclusivity within a group comes from a shared `name`: set on the group in React/Vue (`RadioGroup name="group"`), or on each input in JS/jQuery and Angular.
- `label` sets an option's primary text; `description` (`data-description` in JS/jQuery) adds secondary explanatory text beneath the label.
- Selection state is bound differently per framework: Angular and Vue bind the selected value on the group itself (`[(ngModel)]="group"` in Angular, `v-model="radio"` in Vue) with each option supplying its own `value`; React marks the initially selected option with `defaultChecked={true}`; JS/jQuery marks it with the plain `checked` attribute on that option's input.
- `disabled` makes a single option non-selectable: React `disabled={true}`, Vue `:disabled="true"`, Angular `[disabled]="true"`, JS/jQuery the bare `disabled` attribute.
- `color` (`data-color` in JS/jQuery) sets a preset color per option: `primary`, `secondary`, `success`, `danger`, `warning`, `info`.

## Run it in your project

1. If not signed up yet, or don't own a license, you can [start a free trial](https://mobiscroll.com/starttrial).

2. Clone the repository:

   ```
   git clone https://github.com/acidb/mobiscroll-demos-react.git
   ```

3. If not installed yet, install the Mobiscroll CLI from NPM:

   ```
   npm install -g @mobiscroll/cli
   ```

4. Config Mobiscroll - open a terminal window in the root directory and run:

   ```
   mobiscroll config react
   ```

5. Install dependencies - open a terminal window in the root directory and run:

   ```
   npm install
   ```

6. Run the project:

   ```
   npm run dev
   ```

On a trial, add `--trial` to the config command: `mobiscroll config react --trial`.

Running a demo locally requires a Mobiscroll trial or a license; setup is per framework at https://mobiscroll.com/docs/react/getting-started/installation

## Related demos

- Previous: [Switch](https://demo.mobiscroll.com/react/forms/switch.md) - React switch/toggle demo with or without description. Alternative to the checkbox. Supports disabled styling.
