Slider
Single-value or two-thumb range input on top of Ark UI's slider primitives. Field label, marks, floating thumb label, sizes, colors — keyboard, RTL, and ARIA handled upstream.
The Slider wraps Ark UI's Slider state machine, so keyboard navigation (←/→, Home/End, PageUp/PageDown), RTL flipping, and ARIA wiring come for free. The wrapper layers a styled track / range / thumb, optional marks, and a floating thumb label that follows each thumb. Like the rest of the form family, label / description / error / required come from the built-in Field, and label names every thumb for assistive tech.
Pass a number for a single thumb, or a [number, number] tuple for a two-thumb range. The value shape flows through the whole API — the callbacks echo back the same shape.
import { Slider } from '@42-central/ui-react/slider';
<Slider defaultValue={42} label="Volume" /> {/* single thumb */}
<Slider defaultValue={[25, 60]} label="Price" /> {/* two-thumb range */}label used to be the bubble above each thumb. It is now the field label, as on every other input, and names the thumbs. Rename label to thumbLabel and showLabel to showThumbLabel (the old showLabel still works, deprecated), then give the slider a real label, or an aria-label when it has no visible one.
Playground
Component
Dir
Presets
Modes
Props
Code
<Component size="md" />Sizes
Five track thicknesses — xs through xl. The thumb scales to match.
Code
<Slider size="xs" defaultValue={42} />
<Slider size="sm" defaultValue={42} />
<Slider size="md" defaultValue={42} />
<Slider size="lg" defaultValue={42} />
<Slider size="xl" defaultValue={42} />Colors
Color is orthogonal to the rest of the slider — the accent rides on data-color and the range/thumb reference --c-solid, so every palette in the kit flows through for free, including dark mode and consumer-defined palettes. brand is the default; see Colors for the full system.
brandneutralredorangeyellowgreentealcyanbluepurplepinkCode
import { COLORS } from '@42-central/ui-react';
// ['brand','neutral','red','orange','yellow','green','teal','cyan','blue','purple','pink']
{COLORS.map((c) => (
<Slider key={c} color={c} defaultValue={60} />
))}Marks
Pass marks to paint dots along the track. Each mark is { value, label? } — the label is rendered below the dot. Marks don't restrict input; they're purely visual unless you pair them with a matching step.
Code
<Slider
defaultValue={50}
marks={[
{ value: 0, label: '0' },
{ value: 25, label: '25' },
{ value: 50, label: '50' },
{ value: 75, label: '75' },
{ value: 100, label: '100' },
]}
/>For a segmented stepper, combine marks with step:
<Slider
min={0}
max={10}
step={1}
defaultValue={4}
marks={Array.from({ length: 11 }, (_, i) => ({ value: i }))}
/>Min, max & step
min, max, and step define the value space — nothing here assumes 0–100. The thumb label, marks, and keyboard steps all read from it, so a fractional step and a unit-formatted thumb label compose without extra wiring.
Code
<Slider min={16} max={30} step={0.5} defaultValue={21} thumbLabel={(v) => `${v}°C`} />Range
Pass a [number, number] tuple instead of a single number and the slider renders two thumbs with the filled range between them — for price bands, time windows, or any min/max selection. Everything else carries over: each thumb gets its own thumbLabel bubble, marks between the thumbs read as active, and the callbacks hand you back a [number, number].
Both thumbs are named by label, and each speaks its own value. To tell them apart by name too, pass Ark's per-thumb aria-label array: aria-label={['Minimum price', 'Maximum price']}. A per-thumb name wins over label, and description / error still describe both thumbs.
Use minStepsBetweenThumbs to keep the thumbs from crossing or sitting on top of each other.
testId lands on the root, and each thumb also gets its own `${testId}-thumb-${i}` (0-indexed) — handy for asserting against a specific thumb in a range. See the Testing guide.
Code
<Slider defaultValue={[25, 60]} label="Budget" minStepsBetweenThumbs={5} />Controlled, the value stays a tuple end to end — onChange receives [number, number], no shape guessing:
'use client';
import { useState } from 'react';
import { Slider } from '@42-central/ui-react/slider';
export function PriceRange() {
const [range, setRange] = useState<[number, number]>([25, 60]);
return (
<Slider
value={range}
onChange={setRange}
onChangeEnd={(v) => filterByPrice(v)}
minStepsBetweenThumbs={5}
thumbLabel={(v) => `$${v}`}
/>
);
}Origin
By default the filled range grows from the start of the track. Set origin="center" to fill outward from the midpoint — the right shape for balance, pan, or any signed adjustment around a neutral zero.
Code
<Slider min={-50} max={50} defaultValue={0} origin="center" />Label, description & error
label, description (helper text), and error are built in via Field, like the rest of the form family. label is the slider's accessible name: every thumb (role="slider") is labelled by it, and described by description, or by error once invalid. Passing error flips the track to the invalid (red) state; required adds the semantic flag and a red asterisk.
Code
<Slider defaultValue={60} label="Volume" description="Output level of the speakers." />
<Slider defaultValue={95} label="Volume" error="That will damage your hearing" />With no visible label, name the thumb with Ark's aria-label array instead: aria-label={['Volume']}.
Floating thumb label
thumbLabel accepts any ReactNode, or a function of the thumb's value, and floats above the thumb. By default it appears on hover, focus, or drag. showThumbLabel sets when: "always" (or true) keeps it up, "never" (or false) hides it.
When the function returns a string or a number, it is also each thumb's aria-valuetext, so a screen reader hears the formatted value ("40%") rather than the bare number. Pass Ark's getAriaValueText to say something different.
Code
<Slider thumbLabel="35%" /> {/* on hover/focus */}
<Slider thumbLabel="35%" showThumbLabel="always" /> {/* always visible */}
<Slider thumbLabel="35%" showThumbLabel="never" /> {/* hidden */}
<Slider thumbLabel={null} /> {/* no bubble */}In a server component the function form must come from a
"use client"module. To bind a static node to the current value, drive the slider as a controlled input from a client component (see below).
Controlled
onChange fires on every change (drag, keyboard, click). onChangeEnd fires once the interaction settles — use it to debounce expensive work (network calls, expensive re-renders downstream). Drag the example below: value tracks every tick, committed only updates on release.
value 50%
committed 50%
A controlled value is also how you wire a dynamic thumb label from a static node, since it has to be computed in the same client tree as the slider:
'use client';
import { useState } from 'react';
import { Slider } from '@42-central/ui-react/slider';
export function VolumeSlider() {
const [value, setValue] = useState(50);
return (
<Slider
value={value}
onChange={setValue}
onChangeEnd={(v) => commitToServer(v)}
label="Volume"
thumbLabel={`${value}%`}
/>
);
}Disabled & read-only
disabled dims the track and blocks all interaction. readOnly keeps full contrast and stays focusable — so the value is still announced to assistive tech — but rejects changes. Reach for readOnly to show a value the user can inspect but not edit.
Code
<Slider defaultValue={60} disabled />
<Slider defaultValue={60} readOnly />Forms
Each thumb renders a hidden <input>, so a name wires the slider into native <form> submission and FormData — no controlled state required.
Code
<form action={save}>
<Slider name="volume" defaultValue={60} />
</form>Styling parts
Every part takes a class override through classNames — root, control, track, range, thumb, thumbLabel, and the mark slots. Use it to retheme a one-off without forking the component; the data-color system still drives anything you don't override.
Code
<Slider
defaultValue={65}
classNames={{
track: 'bg-purple-100 dark:bg-purple-950',
range: 'bg-purple-500',
thumb: 'border-purple-500',
}}
/>API
Prop
Type
All other props are forwarded to the underlying Ark Slider.Root.
Accessibility
- Keyboard:
←/→step bystep;Shift + ←/→jumps by 10×;Home/Endsnap tomin/max;PageUp/PageDownjump by 10×. - Every thumb is a
role="slider"named bylabel, and described bydescription, or byerroronce invalid (witharia-errormessage). With no visible label, passaria-label={['…']}; for a range, one name per thumb. - A function
thumbLabelis also the thumb'saria-valuetext, so the formatted value is what gets announced. - Range: each thumb is an independent, focusable control —
Tabmoves between them, and arrows drive whichever is focused.minStepsBetweenThumbsenforces the gap so they never cross. - RTL: when the document
dirisrtl(or a parent sets it), Ark inverts the thumb direction so→still increases the value visually. - Focus ring is keyboard-only (
focus-visible:) so pointer interactions stay quiet. - A hidden
<input>is rendered inside each thumb so the slider integrates with native<form>submission. Passnameto wire it up.
Changelog
- #510
in-*and unnamedgroup-*selectors are scoped to the component's own attribute, so nested or wrapped components no longer pick up an ancestor's orientation, shape, invalid or hover state
- #379
labelis now the field label that names the slider, like every other input; the floating bubble moves tothumbLabel, andshowLabelbecomesshowThumbLabel(the old name still works for now) - #390
Error states follow Figma: error text is red-900 in light and red-500 in dark, invalid fields drop the red wash and keep the red border
- #379
Grouped controls in a field are named by its
labeland described bydescription/error, and a Checkbox'serroris announced - #355
Focus stays on the thumb after an arrow-key step
- #334
Disabled colours are translucent, so pending Timeline bullets and lines and a disabled Slider take the surface's tint instead of a flat grey
- #294
asChildis a compile error onCircularProgress,Progress,Rating,Slider,Divider,Field,InputBaseandPillsInput
- #207
Tracks move onto the kit's translucent wash, and the slider thumb's center is brand-tinted
- #161
Palette-tinted focus rings draw from
--c-text
- #64
Marks and thumb no longer jump outward after the first interaction
Slider
File Item
One file as a row — a picked File or a stored document — with its icon or thumbnail, name, size or date, actions, and an upload status with progress that screen readers hear without the chatter.
Clipboard
Copy-to-clipboard building blocks on Ark UI's Clipboard machine — the one-line Copy icon button, and the full Clipboard compound for a read-only "value + copy button" field.