---
title: "React Forms Colors Example | Mobiscroll"
component: "Forms"
framework: "React"
library_version: "6.1.5"
url: "https://demo.mobiscroll.com/react/forms/button-segmented-stepper-colors"
---

# Colors - React Forms demo

React button, segmented and stepper with color presets for primary, secondary, success, danger and more. For React and Next.JS.

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

## Description

Use presets with pre-defined colors on top of the theme colors. Every theme ships with eight customizable presets that can be used across various components including buttons, segmented and steppers:

- Primary
- Secondary
- Success
- Danger
- Warning
- Info
- Light
- Dark

**Customize the colors or use your own colors:** [Learn how to change the Sass variables for the presets →](https://mobiscroll.com/docs/react/theming/sass-variables)

## What this demo shows

- This example demonstrates the available preset colors (primary, secondary, success, danger, warning, info, light, and dark).
- **Buttons** Shows each preset color applied to buttons.
- **Segmented controls** Applies the same preset colors to segmented controls with text and icons.
- **Selection** Keeps the selected segment visually distinct in every color variant.
- **Steppers** Demonstrates primary, secondary, success, danger, warning, and info color variants for steppers.
- **Consistent styling** Shows how preset colors provide consistent styling across buttons, segmented controls, and steppers.

## Best for

- **Action hierarchy** Distinguishing primary actions from secondary or lower-priority actions.
- **Outcome-based actions** Using success, danger, or warning colors for confirm, delete, and caution-related buttons.
- **Informational actions** Applying the info preset to actions that open help, details, or supporting information.
- **Contrasting controls** Using light and dark presets where controls need to stand out against different backgrounds.
- **Consistent control states** Carrying the same color meaning across buttons, segmented controls, and steppers.

## Tutorial

```html
<div className="mbsc-form-group">
    <div className="mbsc-form-group-title">Button colors</div>
    <div className="mbsc-button-group">
        <Button color="primary">Primary</Button>
        <Button color="secondary">Secondary</Button>
        <Button color="success">Success</Button>
        <Button color="danger">Danger</Button>
        <Button color="warning">Warning</Button>
        <Button color="info">Info</Button>
        <Button color="light">Light</Button>
        <Button color="dark">Dark</Button>
    </div>
</div>
<div className="mbsc-form-group">
    <div className="mbsc-form-group-title">Segmented colors</div>
    <SegmentedGroup name="groupPrimary" color="primary">
        <Segmented value="desktop" icon="home" defaultChecked={true}>Desktop</Segmented>
        <Segmented value="mobile" icon="mobile">Mobile</Segmented>
        <Segmented value="cloud" icon="cloud-upload">Cloud</Segmented>
    </SegmentedGroup>
    <SegmentedGroup name="groupSecondary" color="secondary">
        <Segmented value="desktop" icon="home" defaultChecked={true}>Desktop</Segmented>
        <Segmented value="mobile" icon="mobile">Mobile</Segmented>
        <Segmented value="cloud" icon="cloud-upload">Cloud</Segmented>
    </SegmentedGroup>
    <SegmentedGroup name="groupSuccess" color="success">
        <Segmented value="desktop" icon="home" defaultChecked={true}>Desktop</Segmented>
        <Segmented value="mobile" icon="mobile">Mobile</Segmented>
        <Segmented value="cloud" icon="cloud-upload">Cloud</Segmented>
    </SegmentedGroup>
    <SegmentedGroup name="groupDanger" color="danger">
        <Segmented value="desktop" icon="home" defaultChecked={true}>Desktop</Segmented>
        <Segmented value="mobile" icon="mobile">Mobile</Segmented>
        <Segmented value="cloud" icon="cloud-upload">Cloud</Segmented>
    </SegmentedGroup>
    <SegmentedGroup name="groupWarning" color="warning">
        <Segmented value="desktop" icon="home" defaultChecked={true}>Desktop</Segmented>
        <Segmented value="mobile" icon="mobile">Mobile</Segmented>
        <Segmented value="cloud" icon="cloud-upload">Cloud</Segmented>
    </SegmentedGroup>
    <SegmentedGroup name="groupInfo" color="info">
        <Segmented value="desktop" icon="home" defaultChecked={true}>Desktop</Segmented>
        <Segmented value="mobile" icon="mobile">Mobile</Segmented>
        <Segmented value="cloud" icon="cloud-upload">Cloud</Segmented>
    </SegmentedGroup>
</div>
<div className="mbsc-form-group">
    <div className="mbsc-form-group-title">Stepper colors</div>
    <Stepper label="Primary" color="primary" defaultValue={100} min={-500} max={500} step={100} />
    <Stepper label="Secondary" color="secondary" defaultValue={100} min={-500} max={500} step={100} />
    <Stepper label="Success" color="success" defaultValue={100} min={-500} max={500} step={100} />
    <Stepper label="Danger" color="danger" defaultValue={100} min={-500} max={500} step={100} />
    <Stepper label="Warning" color="warning" defaultValue={100} min={-500} max={500} step={100} />
    <Stepper label="Info" color="info" defaultValue={100} min={-500} max={500} step={100} />
</div>
```

## Code

### JSX

```jsx
import { Button, Page, Segmented, SegmentedGroup, setOptions, Stepper } from '@mobiscroll/react';

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

function App() {
  return (
    <Page>
      <div className="mbsc-form-group">
        <div className="mbsc-form-group-title">Button colors</div>
        <div className="mbsc-button-group">
          <Button color="primary">Primary</Button>
          <Button color="secondary">Secondary</Button>
          <Button color="success">Success</Button>
          <Button color="danger">Danger</Button>
          <Button color="warning">Warning</Button>
          <Button color="info">Info</Button>
          <Button color="light">Light</Button>
          <Button color="dark">Dark</Button>
        </div>
      </div>
      <div className="mbsc-form-group">
        <div className="mbsc-form-group-title">Segmented colors</div>
        <SegmentedGroup name="groupPrimary" color="primary">
          <Segmented value="desktop" icon="home" defaultChecked={true}>
            Desktop
          </Segmented>
          <Segmented value="mobile" icon="mobile">
            Mobile
          </Segmented>
          <Segmented value="cloud" icon="cloud-upload">
            Cloud
          </Segmented>
        </SegmentedGroup>
        <SegmentedGroup name="groupSecondary" color="secondary">
          <Segmented value="desktop" icon="home" defaultChecked={true}>
            Desktop
          </Segmented>
          <Segmented value="mobile" icon="mobile">
            Mobile
          </Segmented>
          <Segmented value="cloud" icon="cloud-upload">
            Cloud
          </Segmented>
        </SegmentedGroup>
        <SegmentedGroup name="groupSuccess" color="success">
          <Segmented value="desktop" icon="home" defaultChecked={true}>
            Desktop
          </Segmented>
          <Segmented value="mobile" icon="mobile">
            Mobile
          </Segmented>
          <Segmented value="cloud" icon="cloud-upload">
            Cloud
          </Segmented>
        </SegmentedGroup>
        <SegmentedGroup name="groupDanger" color="danger">
          <Segmented value="desktop" icon="home" defaultChecked={true}>
            Desktop
          </Segmented>
          <Segmented value="mobile" icon="mobile">
            Mobile
          </Segmented>
          <Segmented value="cloud" icon="cloud-upload">
            Cloud
          </Segmented>
        </SegmentedGroup>
        <SegmentedGroup name="groupWarning" color="warning">
          <Segmented value="desktop" icon="home" defaultChecked={true}>
            Desktop
          </Segmented>
          <Segmented value="mobile" icon="mobile">
            Mobile
          </Segmented>
          <Segmented value="cloud" icon="cloud-upload">
            Cloud
          </Segmented>
        </SegmentedGroup>
        <SegmentedGroup name="groupInfo" color="info">
          <Segmented value="desktop" icon="home" defaultChecked={true}>
            Desktop
          </Segmented>
          <Segmented value="mobile" icon="mobile">
            Mobile
          </Segmented>
          <Segmented value="cloud" icon="cloud-upload">
            Cloud
          </Segmented>
        </SegmentedGroup>
      </div>
      <div className="mbsc-form-group">
        <div className="mbsc-form-group-title">Stepper colors</div>
        <Stepper label="Primary" color="primary" defaultValue={100} min={-500} max={500} step={100} />
        <Stepper label="Secondary" color="secondary" defaultValue={100} min={-500} max={500} step={100} />
        <Stepper label="Success" color="success" defaultValue={100} min={-500} max={500} step={100} />
        <Stepper label="Danger" color="danger" defaultValue={100} min={-500} max={500} step={100} />
        <Stepper label="Warning" color="warning" defaultValue={100} min={-500} max={500} step={100} />
        <Stepper label="Info" color="info" defaultValue={100} min={-500} max={500} step={100} />
      </div>
    </Page>
  );
}

export default App;
```

### TSX

```tsx
import { Button, Page, Segmented, SegmentedGroup, setOptions, Stepper } 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">Button colors</div>
      <div className="mbsc-button-group">
        <Button color="primary">Primary</Button>
        <Button color="secondary">Secondary</Button>
        <Button color="success">Success</Button>
        <Button color="danger">Danger</Button>
        <Button color="warning">Warning</Button>
        <Button color="info">Info</Button>
        <Button color="light">Light</Button>
        <Button color="dark">Dark</Button>
      </div>
    </div>
    <div className="mbsc-form-group">
      <div className="mbsc-form-group-title">Segmented colors</div>
      <SegmentedGroup name="groupPrimary" color="primary">
        <Segmented value="desktop" icon="home" defaultChecked={true}>
          Desktop
        </Segmented>
        <Segmented value="mobile" icon="mobile">
          Mobile
        </Segmented>
        <Segmented value="cloud" icon="cloud-upload">
          Cloud
        </Segmented>
      </SegmentedGroup>
      <SegmentedGroup name="groupSecondary" color="secondary">
        <Segmented value="desktop" icon="home" defaultChecked={true}>
          Desktop
        </Segmented>
        <Segmented value="mobile" icon="mobile">
          Mobile
        </Segmented>
        <Segmented value="cloud" icon="cloud-upload">
          Cloud
        </Segmented>
      </SegmentedGroup>
      <SegmentedGroup name="groupSuccess" color="success">
        <Segmented value="desktop" icon="home" defaultChecked={true}>
          Desktop
        </Segmented>
        <Segmented value="mobile" icon="mobile">
          Mobile
        </Segmented>
        <Segmented value="cloud" icon="cloud-upload">
          Cloud
        </Segmented>
      </SegmentedGroup>
      <SegmentedGroup name="groupDanger" color="danger">
        <Segmented value="desktop" icon="home" defaultChecked={true}>
          Desktop
        </Segmented>
        <Segmented value="mobile" icon="mobile">
          Mobile
        </Segmented>
        <Segmented value="cloud" icon="cloud-upload">
          Cloud
        </Segmented>
      </SegmentedGroup>
      <SegmentedGroup name="groupWarning" color="warning">
        <Segmented value="desktop" icon="home" defaultChecked={true}>
          Desktop
        </Segmented>
        <Segmented value="mobile" icon="mobile">
          Mobile
        </Segmented>
        <Segmented value="cloud" icon="cloud-upload">
          Cloud
        </Segmented>
      </SegmentedGroup>
      <SegmentedGroup name="groupInfo" color="info">
        <Segmented value="desktop" icon="home" defaultChecked={true}>
          Desktop
        </Segmented>
        <Segmented value="mobile" icon="mobile">
          Mobile
        </Segmented>
        <Segmented value="cloud" icon="cloud-upload">
          Cloud
        </Segmented>
      </SegmentedGroup>
    </div>
    <div className="mbsc-form-group">
      <div className="mbsc-form-group-title">Stepper colors</div>
      <Stepper label="Primary" color="primary" defaultValue={100} min={-500} max={500} step={100} />
      <Stepper label="Secondary" color="secondary" defaultValue={100} min={-500} max={500} step={100} />
      <Stepper label="Success" color="success" defaultValue={100} min={-500} max={500} step={100} />
      <Stepper label="Danger" color="danger" defaultValue={100} min={-500} max={500} step={100} />
      <Stepper label="Warning" color="warning" defaultValue={100} min={-500} max={500} step={100} />
      <Stepper label="Info" color="info" defaultValue={100} min={-500} max={500} step={100} />
    </div>
  </Page>
);
export default App;
```

## Implementation notes

- `color` (React/Vue/Angular `color` prop, JS/jQuery `data-color` attribute) accepts all eight presets on `Button`/`mbsc-button`: `primary`, `secondary`, `success`, `danger`, `warning`, `info`, `light`, `dark`.
- The same `color` option applies to `SegmentedGroup`/`mbsc-segmented-group` and each `Segmented`/`mbsc-segmented` child, and to `Stepper`/`mbsc-stepper` - but only six presets are used there: `primary`, `secondary`, `success`, `danger`, `warning`, `info` (no `light`/`dark` variant for segmented or stepper controls).
- Segmented items share a `name` to group them into one control; each item takes an `icon`/`data-icon` plus `defaultChecked` (React), `[checked]` (Angular), `:defaultChecked` (Vue), or the `checked` attribute (JS/jQuery) to mark the initially selected option.
- `Stepper`/`mbsc-stepper` also takes `min`, `max`, `step`, and `label`/`data-label`; this demo sets `min={-500}`, `max={500}`, `step={100}` with an initial value of `100`.
- Framework differences: React `<Button color="primary">`, `<SegmentedGroup name="..." color="primary"><Segmented value="..." icon="..." defaultChecked={true}>...</Segmented></SegmentedGroup>`, `<Stepper color="primary" defaultValue={100} min={-500} max={500} step={100} />`; Angular `<mbsc-button color="primary">`, `<mbsc-segmented-group color="primary"><mbsc-segmented [checked]="true">...</mbsc-segmented></mbsc-segmented-group>`, `<mbsc-stepper color="primary" [(ngModel)]="value" [min]="-500" [max]="500" [step]="100">`; Vue `<MbscButton color="primary">`, `<MbscSegmentedGroup color="primary"><MbscSegmented :defaultChecked="true">...</MbscSegmented></MbscSegmentedGroup>`, `<MbscStepper color="primary" v-model="value" :min="-500" :max="500" :step="100" />`; JS/jQuery plain markup attributes - `data-color`, `data-icon`, the `checked` attribute, and numeric `min`/`step`/`max`/`value` attributes on `input[mbsc-stepper]`/`input[mbsc-segmented]`.

## 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: [Stepper](https://demo.mobiscroll.com/react/forms/stepper.md) - React stepper example with fixed/custom steps and editable values.
