Slider
Single-thumb numeric range track. Optional tick dots and labels mark step increments, custom intervals, or preset positions. Pair with <SliderValue> when you need a numeric readout.
Install
Pull Slider from the barrel for everyday use, or the granular path when you want a tighter bundle.
import { Slider } from "@brika/clay";import { Slider } from "@brika/clay/components/slider";A minimal example
Drop this into a page. Native HTML attributes pass through to the underlying primitive.
import { Slider, SliderValue } from '@brika/clay/components/slider';
import { useState } from 'react';
export default function SliderDefaultDemo() {
const [value, setValue] = useState(50);
return (
<div className="flex w-full max-w-xs items-center gap-2">
<Slider value={value} onChange={setValue} min={0} max={100} step={1} className="flex-1" />
<SliderValue value={value} onChange={setValue} min={0} max={100} step={1} unit="%" />
</div>
);
}Slider, every way
Accessibility
- Built on a native
<input type="range">, all keyboard and AT semantics are native. - Arrow keys adjust value by
step; Home/End jump tomin/max. - Always provide a visible label linked via
htmlForor wrapped<label>. -
SliderValuepairing gives a numeric readout, includeunitfor percentage or currency.
Theme tokens
Every CSS variable Slider reads, with its default and the
dotted path you'd write in a ThemeConfig JSON
to override it. Set any of these in your theme to retune Slider
without touching component code.
Slider tokens
20 tokens--slider-trackcolorvar(--muted)components.slider.trackUnfilled portion of the track.
--slider-fillcolorvar(--primary)components.slider.fillFilled portion of the track (left of the thumb).
--slider-thumbcolorvar(--primary)components.slider.thumbThumb fill color.
--slider-thumb-bordercolorvar(--background)components.slider.thumbBorderThumb border (the halo separating thumb from track).
--slider-tickcolorvar(--foreground)components.slider.tickInactive tick dot color (over the unfilled track). Used with reduced opacity.
--slider-tick-activecolorvar(--primary-foreground)components.slider.tickActiveActive tick dot color (over the filled track). Used with reduced opacity.
--slider-labelcolorvar(--muted-foreground)components.slider.labelTick label text color.
--slider-label-activecolorvar(--foreground)components.slider.labelActiveTick label color when its value matches the current slider value.
--slider-value-containercolorvar(--input-container)components.slider.valueContainerBackground color of the boxed numeric `<SliderValue>` readout/input. Defaults to the input-component fill so the readout matches sibling inputs.
--slider-value-bordercolorvar(--input-border)components.slider.valueBorderBorder color of the `<SliderValue>` input box. Defaults to the input-component border.
--slider-value-labelcolorvar(--input-label)components.slider.valueLabelNumeric text color inside `<SliderValue>`. Defaults to the input-component label color.
--slider-value-ringcolorvar(--ring)components.slider.valueRingBorder color of `<SliderValue>` when its inner input is focus-visible.
--slider-value-unitcolorvar(--muted-foreground)components.slider.valueUnitColor of the optional unit suffix rendered next to the value (e.g. "%", "px").
--slider-track-heightsize0.25remcomponents.slider.trackHeightSlider track thickness.
--slider-thumb-sizesize1remcomponents.slider.thumbSizeSlider thumb diameter.
--slider-thumb-radiusradius9999pxcomponents.slider.thumbRadiusThumb corner radius. Lower for square thumbs.
--slider-tick-sizesize0.25remcomponents.slider.tickSizeTick dot diameter on the track.
--slider-radiusradius9999pxcomponents.slider.radiusTrack corner radius. Set lower for square / brutalist looks.
--slider-thumb-border-widthborder-width2pxcomponents.slider.thumbBorderWidthThumb border width, the contrast halo between the thumb and the track.
--slider-thumb-shadowshadowvar(--shadow-raised)components.slider.thumbShadowThumb drop shadow. Falls back to the global `--shadow-raised`.
Override in a theme
Authoring a theme is plain JSON. Drop overrides under
components.slider, the names
are camelCase versions of the variable suffix.
{
"id": "my-theme",
"name": "My Theme",
"description": "...",
"accentSwatches": ["#000"],
"components": {
"slider": {
"radius": "9999px"
}
}
}
Then apply with applyTheme(myTheme)
(see the theming guide),
scope it to a subtree with themeToCssVars(myTheme, mode),
or consume any token directly in your own JSX with the matching Tailwind utility
(e.g. bg-slider-…) — see the
chips on each token row.
API reference
Props specific to Slider. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.
<Slider />
8 props- numberUpper numeric bound.
- numberLower numeric bound.
- (next: number) => voidCalled with the next value as the user drags or types.
- numberIncrement for keyboard arrows and value snapping.
- numberCurrent numeric value (controlled).
- stringExtra Tailwind classes appended to the slider wrapper.
- SliderTickLabelsRender labels below each tick. Pairs with
ticks. See . - SliderTicksRender tick dots on the track. See .
<SliderValue />
9 props- numberUpper numeric bound.
- numberLower numeric bound.
- (next: number) => voidCalled with the next value as the user drags or types.
- numberIncrement for keyboard arrows and value snapping.
- numberCurrent numeric value (controlled).
- stringExtra Tailwind classes appended to the value-input wrapper.
- numberRound displayed numeric value to this many decimals.
- stringSuffix appended to the displayed value (e.g. "%", "px").
- widthdefault
'w-10'stringTailwind width class for the numeric input. Defaults tow-10.