Angular Range Component

Range

Use our custom Angular Range inputs for consistent cross-browser styling and built-in customization.

Available in Other JavaScript Frameworks

CoreUI Angular Range Component is also available for Bootstrap, React, and Vue. Explore framework-specific implementations below:

Overview

Create custom range controls with <input cFormControl type="range">. The track (the background) and thumb (the value) are both styled to appear the same across browsers. As only Edge Legacy and Firefox supports “filling” their track from the left or right of the thumb as a means to visually indicate progress, we do not currently support it.

import { Component, signal } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { FormControlDirective, FormLabelDirective } from '@coreui/angular';

@Component({
  selector: 'docs-range-overview',
  templateUrl: './range-overview.component.html',
  imports: [FormLabelDirective, FormControlDirective, ReactiveFormsModule, FormsModule]
})
export class RangeOverviewComponent {
  readonly value = signal(50);
}
<label cLabel for="customRange1">Example range - <strong>{{value()}}</strong></label>
<input [(ngModel)]="value" cFormControl id="customRange1" type="range" />

Disabled

Add the disabled boolean attribute on an input to give it a grayed out appearance and remove pointer events.

import { Component } from '@angular/core';
import { FormControlDirective, FormLabelDirective } from '@coreui/angular';

@Component({
  selector: 'docs-range-disabled',
  templateUrl: './range-disabled.component.html',
  imports: [FormLabelDirective, FormControlDirective]
})
export class RangeDisabledComponent {}
<label cLabel for="disabledRange">Disabled range</label>
<input cFormControl disabled id="disabledRange" type="range" />

Min and max

Range inputs have implicit values for min="0" and max="100", respectively. You may specify new values for those using the min and max attributes.

import { Component, signal } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { FormControlDirective, FormLabelDirective } from '@coreui/angular';

@Component({
  selector: 'docs-range-min-max',
  templateUrl: './range-min-max.component.html',
  imports: [FormLabelDirective, FormControlDirective, ReactiveFormsModule, FormsModule]
})
export class RangeMinMaxComponent {
  min = 0;
  max = 6;
  readonly value = signal(4);
}
<label cLabel for="customRange2">Example range - <strong>{{value()}}</strong></label>
<input [(ngModel)]="value" cFormControl id="customRange2" [max]="max" [min]="min" type="range" />

Steps

By default, range inputs “snap” to integer values. To change this, you can specify a step value. In the example below, we double the number of steps by using step="0.5".

import { Component, signal } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { FormControlDirective, FormLabelDirective } from '@coreui/angular';

@Component({
  selector: 'docs-range-steps',
  templateUrl: './range-steps.component.html',
  imports: [FormLabelDirective, FormControlDirective, ReactiveFormsModule, FormsModule]
})
export class RangeStepsComponent {
  readonly value = signal(3);
}
<label cLabel for="customRange3">Example range - <strong>{{value()}}</strong></label>
<input [(ngModel)]="value"
       cFormControl
       id="customRange3"
       max="5"
       min="0"
       step="0.5"
       type="range" />

API reference

Form Module

cFormControl

directive

Works with input html tag of type="range".

Inputs

namedescriptiontypedefault
maxSpecifies the maximum value for the component.number100
minSpecifies the minimum value for the component.number0
stepSpecifies the interval between legal numbers in the component.number1
typeSpecifies the html type of input element.rangerequired
valueThe value attribute of the input.number(max-min)/2
disabledToggle the disabled state for the component.booleanfalse