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

# Colors - jQuery Forms demo

JQuery button, segmented and stepper with color presets for primary, secondary, success, danger and more. For jQuery or jQuery Mobile.

- [Live demo](https://demo.mobiscroll.com/jquery/forms/button-segmented-stepper-colors)
- [View code on GitHub](https://github.com/acidb/mobiscroll-demos-jquery/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), [Angular](https://demo.mobiscroll.com/angular/forms/button-segmented-stepper-colors.md), [React](https://demo.mobiscroll.com/react/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/jquery/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 class="mbsc-form-group">
    <div class="mbsc-form-group-title">Button colors</div>
    <div class="mbsc-button-group">
        <button mbsc-button data-color="primary">Primary</button>
        <button mbsc-button data-color="secondary">Secondary</button>
        <button mbsc-button data-color="success">Success</button>
        <button mbsc-button data-color="danger">Danger</button>
        <button mbsc-button data-color="warning">Warning</button>
        <button mbsc-button data-color="info">Info</button>
        <button mbsc-button data-color="light">Light</button>
        <button mbsc-button data-color="dark">Dark</button>
    </div>
</div>
<div class="mbsc-form-group">
    <div class="mbsc-form-group-title">Segmented colors</div>
    <div mbsc-segmented-group data-color="primary">
        <label>
            Desktop
            <input mbsc-segmented data-color="primary" type="radio" data-icon="home" name="group-primary" checked />
        </label>
        <label>
            Mobile
            <input mbsc-segmented data-color="primary" type="radio" data-icon="mobile" name="group-primary" />
        </label>
        <label>
            Cloud
            <input mbsc-segmented data-color="primary" type="radio" data-icon="cloud-upload" name="group-primary" />
        </label>
    </div>
    <div mbsc-segmented-group data-color="secondary">
        <label>
            Desktop
            <input mbsc-segmented data-color="secondary" type="radio" data-icon="home" name="group-secondary" checked />
        </label>
        <label>
            Mobile
            <input mbsc-segmented data-color="secondary" type="radio" data-icon="mobile" name="group-secondary" />
        </label>
        <label>
            Cloud
            <input mbsc-segmented data-color="secondary" type="radio" data-icon="cloud-upload" name="group-secondary" />
        </label>
    </div>
    <div mbsc-segmented-group data-color="success">
        <label>
            Desktop
            <input mbsc-segmented data-color="success" type="radio" data-icon="home" name="group-success" checked />
        </label>
        <label>
            Mobile
            <input mbsc-segmented data-color="success" type="radio" data-icon="mobile" name="group-success" />
        </label>
        <label>
            Cloud
            <input mbsc-segmented data-color="success" type="radio" data-icon="cloud-upload" name="group-success" />
        </label>
    </div>
    <div mbsc-segmented-group data-color="danger">
        <label>
            Desktop
            <input mbsc-segmented data-color="danger" type="radio" data-icon="home" name="group-danger" checked />
        </label>
        <label>
            Mobile
            <input mbsc-segmented data-color="danger" type="radio" data-icon="mobile" name="group-danger" />
        </label>
        <label>
            Cloud
            <input mbsc-segmented data-color="danger" type="radio" data-icon="cloud-upload" name="group-danger" />
        </label>
    </div>
    <div mbsc-segmented-group data-color="warning">
        <label>
            Desktop
            <input mbsc-segmented data-color="warning" type="radio" data-icon="home" name="group-warning" checked />
        </label>
        <label>
            Mobile
            <input mbsc-segmented data-color="warning" type="radio" data-icon="mobile" name="group-warning" />
        </label>
        <label>
            Cloud
            <input mbsc-segmented data-color="warning" type="radio" data-icon="cloud-upload" name="group-warning" />
        </label>
    </div>
    <div mbsc-segmented-group data-color="info">
        <label>
            Desktop
            <input mbsc-segmented data-color="info" type="radio" data-icon="home" name="group-info" checked />
        </label>
        <label>
            Mobile
            <input mbsc-segmented data-color="info" type="radio" data-icon="mobile" name="group-info" />
        </label>
        <label>
            Cloud
            <input mbsc-segmented data-color="info" type="radio" data-icon="cloud-upload" name="group-info" />
        </label>
    </div>
</div>
<div class="mbsc-form-group">
    <div class="mbsc-form-group-title">Stepper colors</div>
    <label>
        <input mbsc-stepper data-label="Primary" data-color="primary" min="-500" step="100" max="500" value="100" />
    </label>
    <label>
        <input mbsc-stepper data-label="Secondary" data-color="secondary" min="-500" step="100" max="500" value="100" />
    </label>
    <label>
        <input mbsc-stepper data-label="Success" data-color="success" min="-500" step="100" max="500" value="100" />
    </label>
    <label>
        <input mbsc-stepper data-label="Danger" data-color="danger" min="-500" step="100" max="500" value="100" />
    </label>
    <label>
        <input mbsc-stepper data-label="Warning" data-color="warning" min="-500" step="100" max="500" value="100" />
    </label>
    <label>
        <input mbsc-stepper data-label="Info" data-color="info" min="-500" step="100" max="500" value="100" />
    </label>
</div>
```

## Code

### JS

```js
mobiscroll.setOptions({
  theme: 'ios',
  themeVariant: 'light'
});
```

### HTML

```html
<div class="mbsc-form-group">
    <div class="mbsc-form-group-title">Button colors</div>
    <div class="mbsc-button-group">
        <button mbsc-button data-color="primary">Primary</button>
        <button mbsc-button data-color="secondary">Secondary</button>
        <button mbsc-button data-color="success">Success</button>
        <button mbsc-button data-color="danger">Danger</button>
        <button mbsc-button data-color="warning">Warning</button>
        <button mbsc-button data-color="info">Info</button>
        <button mbsc-button data-color="light">Light</button>
        <button mbsc-button data-color="dark">Dark</button>
    </div>
</div>
<div class="mbsc-form-group">
    <div class="mbsc-form-group-title">Segmented colors</div>
    <div mbsc-segmented-group data-color="primary">
        <label>
            Desktop
            <input mbsc-segmented data-color="primary" type="radio" data-icon="home" name="group-primary" checked />
        </label>
        <label>
            Mobile
            <input mbsc-segmented data-color="primary" type="radio" data-icon="mobile" name="group-primary" />
        </label>
        <label>
            Cloud
            <input mbsc-segmented data-color="primary" type="radio" data-icon="cloud-upload" name="group-primary" />
        </label>
    </div>
    <div mbsc-segmented-group data-color="secondary">
        <label>
            Desktop
            <input mbsc-segmented data-color="secondary" type="radio" data-icon="home" name="group-secondary" checked />
        </label>
        <label>
            Mobile
            <input mbsc-segmented data-color="secondary" type="radio" data-icon="mobile" name="group-secondary" />
        </label>
        <label>
            Cloud
            <input mbsc-segmented data-color="secondary" type="radio" data-icon="cloud-upload" name="group-secondary" />
        </label>
    </div>
    <div mbsc-segmented-group data-color="success">
        <label>
            Desktop
            <input mbsc-segmented data-color="success" type="radio" data-icon="home" name="group-success" checked />
        </label>
        <label>
            Mobile
            <input mbsc-segmented data-color="success" type="radio" data-icon="mobile" name="group-success" />
        </label>
        <label>
            Cloud
            <input mbsc-segmented data-color="success" type="radio" data-icon="cloud-upload" name="group-success" />
        </label>
    </div>
    <div mbsc-segmented-group data-color="danger">
        <label>
            Desktop
            <input mbsc-segmented data-color="danger" type="radio" data-icon="home" name="group-danger" checked />
        </label>
        <label>
            Mobile
            <input mbsc-segmented data-color="danger" type="radio" data-icon="mobile" name="group-danger" />
        </label>
        <label>
            Cloud
            <input mbsc-segmented data-color="danger" type="radio" data-icon="cloud-upload" name="group-danger" />
        </label>
    </div>
    <div mbsc-segmented-group data-color="warning">
        <label>
            Desktop
            <input mbsc-segmented data-color="warning" type="radio" data-icon="home" name="group-warning" checked />
        </label>
        <label>
            Mobile
            <input mbsc-segmented data-color="warning" type="radio" data-icon="mobile" name="group-warning" />
        </label>
        <label>
            Cloud
            <input mbsc-segmented data-color="warning" type="radio" data-icon="cloud-upload" name="group-warning" />
        </label>
    </div>
    <div mbsc-segmented-group data-color="info">
        <label>
            Desktop
            <input mbsc-segmented data-color="info" type="radio" data-icon="home" name="group-info" checked />
        </label>
        <label>
            Mobile
            <input mbsc-segmented data-color="info" type="radio" data-icon="mobile" name="group-info" />
        </label>
        <label>
            Cloud
            <input mbsc-segmented data-color="info" type="radio" data-icon="cloud-upload" name="group-info" />
        </label>
    </div>
</div>
<div class="mbsc-form-group">
    <div class="mbsc-form-group-title">Stepper colors</div>
    <label>
        <input mbsc-stepper data-label="Primary" data-color="primary" min="-500" step="100" max="500" value="100" />
    </label>
    <label>
        <input mbsc-stepper data-label="Secondary" data-color="secondary" min="-500" step="100" max="500" value="100" />
    </label>
    <label>
        <input mbsc-stepper data-label="Success" data-color="success" min="-500" step="100" max="500" value="100" />
    </label>
    <label>
        <input mbsc-stepper data-label="Danger" data-color="danger" min="-500" step="100" max="500" value="100" />
    </label>
    <label>
        <input mbsc-stepper data-label="Warning" data-color="warning" min="-500" step="100" max="500" value="100" />
    </label>
    <label>
        <input mbsc-stepper data-label="Info" data-color="info" min="-500" step="100" max="500" value="100" />
    </label>
</div>
```

## 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-jquery.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 jquery
   ```

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 jquery --trial`.

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

## Related demos

- Previous: [Stepper](https://demo.mobiscroll.com/jquery/forms/stepper.md) - JQuery stepper example with fixed/custom steps and editable values.
