4.2.0
Core

Slider

A draggable control for picking a value — or several — from within a bounded range.

Slider

Radix always takes an array, even for one thumb — `defaultValue={[40]}`, never a bare number. The knob is `control-thumb`, a theme-invariant role: a knob should not flip with the theme the way the track and range do.

Usage

import { Slider } from '@oceanic-hub/brand-system'

The value is always an array, even for one thumb: defaultValue={[50]}, never a bare number. That is Radix's shape, not this package's preference — Base UI takes a scalar, and passing one here is a compile error rather than a slider that silently renders with no thumb at all.

Multiple thumbs come free, and that is the deliberate superset. The implementation maps over the value array and renders one Thumb per entry, so a range slider is defaultValue={[20, 80]} and a three-way split is defaultValue={[20, 50, 80]} — neither needs anything else from this package. Upstream's own file hard-codes a single Thumb, so its own range example is broken; core-layer.md's parity rule is a floor, not a mould, and this is the case where the floor is higher than the ceiling it was measured against.

Controlled use is value plus onValueChange, fired on every drag frame; onValueCommit fires once, on release, which is the right moment for a save or a fetch that should not run on every pixel of travel.

The knob is bg-control-thumb, one of the THEME-INVARIANT roles — a knob should not flip colour with the theme the way the track and range do, and that is exactly the job this role exists for. The track is bg-surface-sunken, the recessed ground, named rather than upstream's translucent tint of its own fill colour.

orientation="vertical" renders a proper vertical rail. Root, Track and Range all key off data-orientation; the thumb is square, so it is the one part that needs no axis. The height is the caller's own decision (a volume rail is however tall its parent is), so set one via className; the component supplies the column direction and a default rail width.

A slider's accessible name belongs on its thumb, and thumbProps is the only way it gets there. Radix puts role="slider" on the thumb rather than on the root, and the root is a span — not a labelable element — so neither <label htmlFor> nor an aria-label on the root reaches the thing a reader is being told about (@OCE-1873). Leave it out and Radix supplies its own: nothing at all for one thumb, "Minimum" and "Maximum" for two, "Value 1 of 3" for more — a position, never a quantity. One object names a single-thumb slider; an array names a range's ends in value order, because two thumbs answering to the same words are indistinguishable to anyone listening rather than looking. Inside a Field, reach for aria-labelledby pointing at the FieldLabel — that is the association htmlFor cannot make, and Field's page shows the composed shape.

RTL is not supported, the same refusal recorded once, in pairings.json under direction, rather than repeated on every page that would otherwise show it.

Naming the thumbs

Radix puts role="slider" on the thumb, so the accessible name goes there and nowhere else: one object names a single-thumb slider, and an array names a range's ends in value order, because two thumbs answering to the same words are indistinguishable to anyone listening.

One thumb, one name — “Daily send cap”.

Two thumbs, two names — “Lowest score” and “Highest score”, in value order.

Range

Two values in the array gives two thumbs and a filled span between them. The same mechanism scales to any count — Radix renders one Thumb per entry — so a three-way split needs nothing extra, unlike upstream's own file, which hard-codes a single Thumb.

Controlled

value plus onValueChange — the array shape stays the array shape, it just moves from a default to state a caller owns. Reach for it the moment something else on the page needs to read the number, not only the slider itself.

Alert threshold70%

Disabled

Fades the track, the range and every thumb, and stops the drag. The value shown stays whatever it was — disabling a slider is not the same as resetting it.

Vertical

Root, Track and Range all key off data-orientation; the thumb is square, so it is the one part that needs no axis. The rail's height is the caller's own className, the same way a volume rail is however tall its parent is.

API Reference

See the Slider API page for every prop of every part, with types, defaults and the contract that pins them.

On this page