Range Slider
A range on one track: two thumbs that never cross, in the look of the app's Slider. The value is the pair — one Signal Forms field.
Usage
Usage
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScRangeSlider, ScRangeSliderThumb } from '@semantic-components/ui';
/** Two thumbs on one track, the range between them: the value is the pair. */@Component({ selector: 'app-range-slider-usage-demo', imports: [ScRangeSlider, ScRangeSliderThumb], template: ` <div scRangeSlider [(value)]="range" class="max-w-xs"> <input scRangeSliderThumb aria-label="Minimum" />Anatomy
A group holding the value and drawing the track; in it, a native range per thumb — the first is from, the second to. Each thumb is named by you; the group by its field's label. Its ends are the form's: min and max on each value of the pair, in the schema (applyEach).
import { ScRangeSlider, ScRangeSliderThumb } from '@semantic-components/ui';<div scRangeSlider [formField]="…" #range="scRangeSlider"> <input scRangeSliderThumb aria-label="…" /> <input scRangeSliderThumb aria-label="…" /></div>Accessibility
- Each thumb is a native range: Tab reaches it; the arrows move it by the step, Page Up and Page Down by more, Home and End to the ends (mirrored right to left). It stops at the other thumb.
- Name each thumb (aria-label: "Minimum price"); in a field, the group is named by its label. format reads the values out (aria-valuetext: "€200").
- A press on the track brings the nearer thumb; dragged into the other, a thumb pushes it along. With both on one spot, the direction of the drag chooses the thumb.
- A description is read with each thumb; invalid once touched (aria-invalid, from Signal Forms).
Examples
Label and value
€200 – €800
Nights from this price to that one.
import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, applyEach, form, max, min } from '@angular/forms/signals';import { ScField, ScFieldDescription, ScLabel, ScRangeSlider, ScRangeSliderThumb,} from '@semantic-components/ui';Steps
30 – 70
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScRangeSlider, ScRangeSliderThumb } from '@semantic-components/ui';
/** By tens, and two steps apart at least (minStepsBetweenValues): the thumbs stop 20 short of each other. */@Component({ selector: 'app-steps-range-slider-demo', imports: [ScRangeSlider, ScRangeSliderThumb], template: ` <div class="flex w-full max-w-xs flex-col gap-3"> <divVertical
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScRangeSlider, ScRangeSliderThumb } from '@semantic-components/ui';
/** Upright: the values grow upward, ArrowUp raises a thumb. */@Component({ selector: 'app-vertical-range-slider-demo', imports: [ScRangeSlider, ScRangeSliderThumb], template: ` <div scRangeSlider orientation="vertical" [(value)]="range" class="h-48"> <input scRangeSliderThumb aria-label="Lowest" />Form
{
"budget": [
400,
450
]
}import { JsonPipe } from '@angular/common';import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, applyEach, form, max, min, validate,} from '@angular/forms/signals';Without a form
15 sec – 65 sec
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScRangeSlider, ScRangeSliderThumb } from '@semantic-components/ui';
/** Without a form: a clip's start and end, its ends written as [min] and [max] (0 to the clip's length), in seconds. */@Component({ selector: 'app-trim-range-slider-demo', imports: [ScRangeSlider, ScRangeSliderThumb], template: ` <div class="flex w-full max-w-xs flex-col gap-3"> <divDisabled
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScRangeSlider, ScRangeSliderThumb } from '@semantic-components/ui';
/** Disabled: neither thumb takes the pointer or the focus. */@Component({ selector: 'app-disabled-range-slider-demo', imports: [ScRangeSlider, ScRangeSliderThumb], template: ` <div scRangeSlider disabled [(value)]="range" class="max-w-xs"> <input scRangeSliderThumb aria-label="Minimum" />RTL
من 25 إلى 75
import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation, signal } from '@angular/core';import { ScRangeSlider, ScRangeSliderThumb } from '@semantic-components/ui';
/** In a right-to-left page: from the right, the arrows mirrored, the values in Arabic digits (LOCALE_ID). */@Component({ selector: 'app-rtl-range-slider-demo', imports: [Dir, ScRangeSlider, ScRangeSliderThumb], template: ` <div dir="rtl" lang="ar" class="flex w-full max-w-xs flex-col gap-3">API reference
Each part takes class, merged over the style (cn: a later class wins).
| Part | Selector | Description |
|---|---|---|
ScRangeSlider | div[scRangeSlider] | A group (named by its field's label) drawing the track and the range: value, the pair [from, to] (a [formField], or two-way); its ends: with a form, the schema's (applyEach: min and max on each value), without one min and max (0 and 100 by default); step; minStepsBetweenValues; orientation ('horizontal', 'vertical'); disabled; format (Intl.NumberFormat, in LOCALE_ID). exportAs scRangeSlider: formatted(), lowest(), highest(). |
ScRangeSliderThumb | input[scRangeSliderThumb] | A native range in the style's Slider thumb: the first is from, the second to. It stops at the other; its aria-valuetext from format. |