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

# Colors - Angular Forms demo

Angular button, segmented and stepper with color presets for primary, secondary, success, danger and more.

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

## Code

### Component

```ts
import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { MbscModule, setOptions } from '@mobiscroll/angular';

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

@Component({
  selector: 'app-root', 
  templateUrl: './app.component.html',
  standalone: true,
  imports: [CommonModule, FormsModule, MbscModule],
})
export class AppComponent {
  primary = 100;
  secondary = 100;
  success = 100;
  danger = 100;
  warning = 100;
  info = 100;
}
```

### Template

```html
<mbsc-page>
  <div class="mbsc-form-group">
    <div class="mbsc-form-group-title">Button colors</div>
    <div class="mbsc-mbsc-button-group">
      <mbsc-button color="primary">Primary</mbsc-button>
      <mbsc-button color="secondary">Secondary</mbsc-button>
      <mbsc-button color="success">Success</mbsc-button>
      <mbsc-button color="danger">Danger</mbsc-button>
      <mbsc-button color="warning">Warning</mbsc-button>
      <mbsc-button color="info">Info</mbsc-button>
      <mbsc-button color="light">Light</mbsc-button>
      <mbsc-button color="dark">Dark</mbsc-button>
    </div>
  </div>
  <div class="mbsc-form-group">
    <div class="mbsc-form-group-title">Segmented colors</div>
    <mbsc-segmented-group name="groupPrimary" color="primary">
      <mbsc-segmented value="desktop" icon="home" [checked]="true">Desktop</mbsc-segmented>
      <mbsc-segmented value="mobile" icon="mobile">Mobile</mbsc-segmented>
      <mbsc-segmented value="cloud" icon="cloud-upload">Cloud</mbsc-segmented>
    </mbsc-segmented-group>
    <mbsc-segmented-group name="groupSecondary" color="secondary">
      <mbsc-segmented value="desktop" icon="home" [checked]="true">Desktop</mbsc-segmented>
      <mbsc-segmented value="mobile" icon="mobile">Mobile</mbsc-segmented>
      <mbsc-segmented value="cloud" icon="cloud-upload">Cloud</mbsc-segmented>
    </mbsc-segmented-group>
    <mbsc-segmented-group name="groupSuccess" color="success">
      <mbsc-segmented value="desktop" icon="home" [checked]="true">Desktop</mbsc-segmented>
      <mbsc-segmented value="mobile" icon="mobile">Mobile</mbsc-segmented>
      <mbsc-segmented value="cloud" icon="cloud-upload">Cloud</mbsc-segmented>
    </mbsc-segmented-group>
    <mbsc-segmented-group name="groupDanger" color="danger">
      <mbsc-segmented value="desktop" icon="home" [checked]="true">Desktop</mbsc-segmented>
      <mbsc-segmented value="mobile" icon="mobile">Mobile</mbsc-segmented>
      <mbsc-segmented value="cloud" icon="cloud-upload">Cloud</mbsc-segmented>
    </mbsc-segmented-group>
    <mbsc-segmented-group name="groupWarning" color="warning">
      <mbsc-segmented value="desktop" icon="home" [checked]="true">Desktop</mbsc-segmented>
      <mbsc-segmented value="mobile" icon="mobile">Mobile</mbsc-segmented>
      <mbsc-segmented value="cloud" icon="cloud-upload">Cloud</mbsc-segmented>
    </mbsc-segmented-group>
    <mbsc-segmented-group name="groupInfo" color="info">
      <mbsc-segmented value="desktop" icon="home" [checked]="true">Desktop</mbsc-segmented>
      <mbsc-segmented value="mobile" icon="mobile">Mobile</mbsc-segmented>
      <mbsc-segmented value="cloud" icon="cloud-upload">Cloud</mbsc-segmented>
    </mbsc-segmented-group>
  </div>
  <div class="mbsc-form-group">
    <div class="mbsc-form-group-title">Stepper colors</div>
    <mbsc-stepper label="Primary" color="primary" [(ngModel)]="primary" [min]="-500" [max]="500" [step]="100"> </mbsc-stepper>
    <mbsc-stepper label="Secondary" color="secondary" [(ngModel)]="secondary" [min]="-500" [max]="500" [step]="100"> </mbsc-stepper>
    <mbsc-stepper label="Success" color="success" [(ngModel)]="success" [min]="-500" [max]="500" [step]="100"> </mbsc-stepper>
    <mbsc-stepper label="Danger" color="danger" [(ngModel)]="danger" [min]="-500" [max]="500" [step]="100"> </mbsc-stepper>
    <mbsc-stepper label="Warning" color="warning" [(ngModel)]="warning" [min]="-500" [max]="500" [step]="100"> </mbsc-stepper>
    <mbsc-stepper label="Info" color="info" [(ngModel)]="info" [min]="-500" [max]="500" [step]="100"></mbsc-stepper>
  </div>
</mbsc-page>
```

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

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

   ```
   npm install
   ```

6. Run the project:

   ```
   ng serve
   ```

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

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

## Related demos

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