Skip to content
ArcadiaDesign
40

TSX

A value along a track, for a setting a person tunes by feel and watches change: a size, a level. A thin bar with round ends and a round thumb in ink; dragged, pressed where it should go, or set from the keyboard. min, max and step bound it; valueText says the value in words to a reader. When the exact number matters, a field says it better.

Examples

A size

taper widens the track toward its larger end, scale="root" makes the steps finer at the thin end where a pixel shows, and ink puts the colour being sized on its thumb; over a picture it takes a surface of its own (--slider-bg).

onActiveChange tells while it is being set, so what it sizes can be shown at its true scale meanwhile.

States

At rest
On a surface
Disabled

rootStyle takes where the slider sits and the knobs below.

--slider-length
Ref<Space | Measure> | `calc(${Ref<Space>} * ${number})` | "100%"Default calc(var(--space-16) * 3)
Its length along its axis. Default 192.
--slider-bg
PaintDefault transparent
The surface it stands on: none by default; a raised one where it stands over a picture.
--slider-track
PaintDefault var(--fill-2)
Its track.
--slider-thumb
PaintDefault var(--icon-1)
Its thumb, where no ink is given.

A slider named by its required label, with its value, its bounds and its orientation; valueText gives the value in words. Its hit area is a control's full height, whatever the thin track. Up and Right raise it, in either direction of writing.

Arrow keys
One step
Page Up, Page Down
A tenth of its range
Home, End
Its least and its most

Slider

labelrequired
string
Required: its name for assistive technology ("Size").
value
number
Controlled value.
defaultValue
numberDefault min
Initial value when uncontrolled.
onValueChange
(value: number) => void
Called with each new value as it is set.
onActiveChange
(active: boolean) => void
While it is being set, by a drag or a key, until it lets go or loses focus: what it sets can be shown at its true scale meanwhile.
min
numberDefault 0
max
numberDefault 100
step
numberDefault 1
orientation
"horizontal" | "vertical"Default "horizontal"
horizontal grows to the inline end; vertical grows upward.
scale
"linear" | "root"Default "linear"
root: the travel is the square root of the value's share, so steps are finer toward the start, where a pixel shows.
taper
booleanDefault false
The track widens from its start to its end: the slider sets a size.
ink
string
The colour its thumb shows, #rrggbb: what the size is of (an ink).
valueText
(value: number) => string
What a reader hears for a value ("12 pixels"). Default the number.
disabled
booleanDefault false
rootStyle
RootStyle<SliderKnobs>
Typed StyleX override: layout and the --slider-* knobs.

Rest props go to <div> props.