Slider

A styled native range input for picking a number from a continuous or stepped range, where the exact value matters less than its position, such as volume or a price limit.

  • vig-slider
Import
import { Slider } from '@vigdx/ui/slider';

Basic

Bind [(value)] to a number | null signal and set min , max (default 0 and 100) and step . showValue prints the current value next to the label. The filled part of the track follows the reading direction.

Volume: 40 · Team: 6

Value template

valueTemplate formats the shown value and aria-valuetext ; {0} is replaced by the number formatted for the active locale, so units and decimals read correctly.

Ticks

[ticks]="true" draws a mark per step (up to 50 steps). An array of values draws labelled marks at those values instead. Ticks are visual only.

Empty, hidden label, disabled, read-only and error

An empty slider ( null ) rests at min until moved. hideLabel keeps the label for screen readers only. readonly keeps the thumb focusable but ignores changes. Errors show once the slider is touched and invalid .

Rests at the minimum until moved.

Label hidden, still announced.

Book at least 10 seats.

Reactive Forms

Import VigValueAccessor next to the component to use formControlName , [formControl] or ngModel .

{
  "bass": 3,
  "treble": -2
}

Signal Forms

vig-slider implements FormValueControl<number | null> . Schema min() and max() rules bind to the slider's range; other rules, such as this validate() , show their message once the slider is touched.

50 to 500 €, in steps of 20 €.

Valid: yes · 120

Styling hooks

Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="slider"][data-part="header"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.

Scope: [data-scope="slider"]

Slider styling hooks
Part Element data-state
header Row of the label and the value. —
label The <label> . —
value The formatted value ( showValue ). —
input The native range input: track and thumb are its pseudo-elements. —
ticks Row of tick marks ( ticks ). —
tick One tick mark with its label. —
hint The vig-hint (a display: contents host; style its text part). —
disabled-reason The vig-hint with the disabled reason ( display: contents ). —
error The vig-field-error (a display: contents host; style its message part). —

Accessibility

  • A native <input type="range">, exposed as a slider: the arrows change the value by step, Page Up and Page Down by larger steps, Home and End jump to min and max.
  • It is named by a real <label for>, also with hideLabel. The printed value is hidden from screen readers because it is already announced through aria-valuetext.
  • Use valueTemplate to add units, so "15 %" is announced rather than "15".
  • readonly and an invalid state set aria-readonly and aria-invalid. The slider role does not support aria-required, so required adds a visually hidden "Required" (requiredLabel) to the description; hint and error are linked through aria-describedby too.
  • The track is a light --color-muted bar inside a --color-border-control border: the border is at least 3:1 against the page like other control boundaries, and the fill at least 3:1 against the track. Forced-colors mode draws both with system colors.
  • Sliders are hard to set precisely on touch screens; for exact numbers offer a number input instead or next to it.

API

Slider

vig-slider component

Range slider built on the native <input type="range">, so keyboard (arrows, Page Up/Down, Home/End) and assistive-tech support come from the browser. Styled entirely with tokens: track --color-muted inside a --color-border-control border, fill --color-primary, thumb --color-background with a primary border. Empty is null; an empty slider rests at min until moved.

Slider props
Name Type Default Description
dirtybooleanfalse
—
disabledbooleanfalse
—
disabledReasonsreadonly WithOptionalFieldTree<DisabledReason>[][]
—
errorMessagesRecord<string, string>—
—
errorsreadonly ValidationError.WithOptionalFieldTree[][]
—
hiddenbooleanfalse
—
hideLabelbooleanfalse

Keeps the label for assistive tech only.

hintstring | undefinedundefined
—
invalidbooleanfalse
—
label required string—
—
maxnumber | undefined100
—
minnumber | undefined0
—
namestring''
—
pendingbooleanfalse
—
readonlybooleanfalse
—
requiredbooleanfalse
—
requiredLabelstring | undefinedundefined

Screen-reader text conveying required: the slider role does not support aria-required, so it is part of the description instead.

showValuebooleanfalse

Shows the formatted value beside the label.

stepnumber1
—
ticksboolean | readonly number[]false

Tick marks under the track: true draws one per step (up to 50 steps), an array draws labelled marks at those values.

touchedbooleanfalse
—
value model number | nullnull
—
valueTemplatestring | ((value: number) => string)'{0}'

Formats the value for display, aria-valuetext and tick labels: a function of the number, e.g. (n) => n + ' km', or a string where {0} is replaced by the locale-formatted number, e.g. '{0} %'.

VigValueAccessor

directive

Bridges the vigdx form fields to Reactive Forms (formControl, formControlName) and template-driven forms (ngModel). Import it next to the component; Signal Forms ([formField]) need no accessor.

VigValueAccessor methods
Signature Description
registerOnChange(fn: (value: unknown) => void): void
—
registerOnTouched(fn: () => void): void
—
setDisabledState(disabled: boolean): void
—
writeValue(value: unknown): void
—

Are you sure?