Primitives
Select a value within a range.
Import the Slider primitives from ng-primitives/slider.
import { NgpSlider, NgpSliderTrack, NgpSliderRange, NgpSliderThumb } from 'ng-primitives/slider';
Assemble the slider directives in your template.
<div ngpSlider>
<div ngpSliderTrack>
<div ngpSliderRange></div>
</div>
<div ngpSliderThumb></div>
</div>
Create a reusable component that uses the slider directives.
Generate a reusable slider component using the Angular CLI.
ng g ng-primitives:primitive slider
path: The path at which to create the component file.prefix: The prefix to apply to the generated component selector.componentSuffix: The suffix to apply to the generated component class name.fileSuffix: The suffix to apply to the generated component file name. Defaults to component.exampleStyles: Whether to include example styles in the generated component file. Defaults to true.Here are some additional examples of how to use the Slider primitives.
Display the slider in a vertical orientation by setting ngpSliderOrientation="vertical".
Display the current value in a tooltip that follows the slider thumb. Use ngpTooltipTriggerTrackPosition to enable smooth position updates during drag.
Display a preview tooltip as you hover over the track, showing what value would be selected at that position. The tooltip also appears on the thumb during drag. Uses ngpTooltipTriggerPosition for programmatic positioning.
The slider automatically integrates with the form field primitives.
The following directives are available to import from the ng-primitives/slider package:
The following data attributes are available to style the slider:
| Attribute | Description | Value |
|---|---|---|
data-disabled |
Applied when the slider is disabled. | - |
data-orientation |
The orientation of the slider. | horizontal | vertical |
The following data attributes are available to style the slider track:
| Attribute | Description | Value |
|---|---|---|
data-disabled |
Applied when the slider is disabled. | - |
data-orientation |
The orientation of the slider. | horizontal | vertical |
The following data attributes are available to style the slider range:
| Attribute | Description | Value |
|---|---|---|
data-disabled |
Applied when the slider is disabled. | - |
data-orientation |
The orientation of the slider. | horizontal | vertical |
The following data attributes are available to style the thumb:
| Attribute | Description | Value |
|---|---|---|
data-orientation |
The orientation of the slider. | horizontal | vertical |
data-disabled |
Applied when the 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. | - |
The following directives are available to import from the ng-primitives/slider package:
Adheres to the Slider WAI-ARIA design pattern.
Copyright © 2026 Angular Primitives
This site is powered by Netlify