Primitives
Select a range of values within a defined range.
import { Component, signal } from "@angular/core";
import {
NgpRangeSlider,
NgpRangeSliderRange,
NgpRangeSliderThumb,
NgpRangeSliderTrack,
} from "ng-primitives/slider";
@Component({
selector: "app-range-slider",
imports: [
NgpRangeSlider,
NgpRangeSliderRange,
NgpRangeSliderThumb,
NgpRangeSliderTrack,
],
styles: `
[ngpRangeSlider] {
display: flex;
position: relative;
width: 200px;
height: 20px;
touch-action: none;
user-select: none;
align-items: center;
}
[ngpRangeSliderTrack] {
position: relative;
height: 5px;
width: 100%;
border-radius: 999px;
background-color: var(--ngp-background-secondary);
}
[ngpRangeSliderRange] {
position: absolute;
height: 100%;
border-radius: 999px;
background-color: var(--ngp-background-inverse);
}
[ngpRangeSliderThumb] {
position: absolute;
display: block;
height: 20px;
width: 20px;
border-radius: 10px;
background-color: white;
box-shadow: var(--ngp-button-shadow);
outline: none;
transform: translateX(-50%);
z-index: 1;
}
[ngpRangeSliderThumb][data-focus-visible] {
outline: 2px solid var(--ngp-focus-ring);
outline-offset: 0;
}
[ngpRangeSliderThumb][data-thumb="high"] {
z-index: 2;
}
`,
template: `
<div
[ngpRangeSliderLow]="low()"
[ngpRangeSliderHigh]="high()"
(ngpRangeSliderLowChange)="low.set($event)"
(ngpRangeSliderHighChange)="high.set($event)"
ngpRangeSlider
>
<div ngpRangeSliderTrack>
<div ngpRangeSliderRange></div>
</div>
<div ngpRangeSliderThumb></div>
<div ngpRangeSliderThumb></div>
</div>
`,
})
export default class RangeSliderExample {
low = signal(25);
high = signal(75);
}
Import the Range Slider primitives from ng-primitives/slider
.
import {
NgpRangeSlider,
NgpRangeSliderTrack,
NgpRangeSliderRange,
NgpRangeSliderThumb,
} from 'ng-primitives/slider';
Assemble the range slider directives in your template.
<div ngpRangeSlider>
<div ngpRangeSliderTrack>
<div ngpRangeSliderRange></div>
</div>
<div ngpRangeSliderThumb></div>
<div ngpRangeSliderThumb></div>
</div>
The following directives are available to import from the ng-primitives/slider
package:
Apply the `ngpRangeSlider` directive to an element that represents the range slider and contains the track, range, and thumbs. The low value of the range slider.
The high value of the range slider.
The minimum value of the range slider.
The maximum value of the range slider.
The step value of the range slider.
The orientation of the range slider.
The disabled state of the range slider.
Emits when the low value changes.
Emits when the high value changes.
[ngpRangeSlider]
ngpRangeSlider
The following data attributes are available to style the range slider:
Attribute | Description | Value |
---|---|---|
data-disabled |
Applied when the range slider is disabled. | - |
data-orientation |
The orientation of the range slider. | horizontal | vertical |
Apply the `ngpRangeSliderTrack` directive to an element that represents the track of the range slider.[ngpRangeSliderTrack]
ngpRangeSliderTrack
The following data attributes are available to style the slider track:
Attribute | Description | Value |
---|---|---|
data-disabled |
Applied when the range slider is disabled. | - |
data-orientation |
The orientation of the range slider. | horizontal | vertical |
Apply the `ngpRangeSliderRange` directive to an element that represents the range between the low and high values.[ngpRangeSliderRange]
ngpRangeSliderRange
The following data attributes are available to style the slider range:
Attribute | Description | Value |
---|---|---|
data-disabled |
Applied when the range slider is disabled. | - |
data-orientation |
The orientation of the range slider. | horizontal | vertical |
Apply the `ngpRangeSliderThumb` directive to an element that represents a thumb of the range slider.
Each thumb can be configured to control either the 'low' or 'high' value.[ngpRangeSliderThumb]
ngpRangeSliderThumb
The following data attributes are available to style the thumb:
Attribute | Description | Value |
---|---|---|
data-orientation |
The orientation of the range slider. | horizontal | vertical |
data-disabled |
Applied when the range slider is disabled. | - |
data-hover |
Applied when the slider thumb is hovered. | - |
data-focus-visible |
Applied when the slider thumb is focused. | - |
data-press |
Applied when the slider thumb is pressed. | - |
data-thumb |
Indicates which value this thumb controls. | low | high |
Adheres to the Multi-Thumb Slider WAI-ARIA design pattern.
Each thumb can be focused and controlled independently:
Copyright © 2025 Angular Primitives