Rime

Slider

Picks a number or a range by dragging along a track, with steps, marks and a value readout.

Slider takes one value or a [low, high] range (two thumbs that never cross). The chosen span is drawn in the accent gradient over a recessed track. step snaps every value, marks draw labelled ticks, and showValue prints the formatted value beside the label.

Use it where the exact number matters less than its position in a range (volume, a price filter, a threshold). When the exact number matters, pair it with a TextInput or use the input alone.

Installation

npx shadcn@latest add KezLahd/rime/slider

Also installs: base, field.

Usage

import { Slider } from "@/components/ui";

<Slider label="Volume" value={volume} onValueChange={setVolume} showValue formatValue={(n) => `${n}%`} />

Examples

Single value

Volume

Range with marks

Order value

Step and disabled

Step 5
Disabled

API

Generated from the component's TypeScript types and JSDoc (scripts/gen-ui-registry.mjs), so it always matches the source.

Slider

Slider props
PropTypeDefaultDescription
minnumber0
maxnumber100
stepnumber1
largeStepnumberPageUp and PageDown move by this much. Defaults to a tenth of the range, rounded to the step.
marksReadonlyArray<{ value: number; label?: string }>Ticks under the track, optionally labelled: [{ value: 0, label: "0" }, { value: 50 }].
formatValue(value: number) => string(v: number) => String(v)Formats the value for aria-valuetext and the value readout: (v) => `${v}%`.
showValuebooleanShows the formatted value (or range) to the right of the label row.
labelstringVisible label above the track. Without it, pass aria-label.
aria-labelstring
disabledboolean
namestringPosts the value (a range posts two inputs, name[0] and name[1]).
classNamestring
valueRequirednumber | readonly [number, number]One thumb.
onValueChangeRequired(value: number) => void | (value: [number, number]) => void

Theme tokens

Per-component tokens are undeclared by default, so the default shown is the fallback the CSS uses. Set one at :root (or in theme.css) to restyle every instance. Live values are read from this page, so they follow the Rime Studio.

Slider per-component tokens
TokenDefaultLive value
--slider-fillvar(--brand-gradient)…
--slider-thumb-bgvar(--surface-solid)…
--slider-thumb-size18px…
--slider-track-bgvar(--recess-fill-hover)…
--slider-track-h6px…

System tokens it reads

Slider system tokens
TokenDefaultLive value
--brandtokens.css…
--brand-gradienttokens.css…
--durtokens.css…
--easetokens.css…
--focus-ringtokens.css…
--ink-disabledtokens.css…
--ink-headingtokens.css…
--ink-mutedtokens.css…
--ink-secondarytokens.css…
--line-inputtokens.css…
--r-fulltokens.css…
--recess-fill-hovertokens.css…
--rgb-contacttokens.css…
--surface-solidtokens.css…
--text-captiontokens.css…
--text-smalltokens.css…

Accessibility

  • Each thumb is role="slider" with aria-valuemin, aria-valuemax, aria-valuenow and aria-valuetext (from formatValue), named by the label; range thumbs are named "minimum" and "maximum".
  • Keyboard: arrows step, PageUp and PageDown take a large step (a tenth of the range by default), Home and End jump to the ends.
  • Pressing anywhere on the track moves the nearest thumb there and focuses it.

Do and don't

Do

  • Format values in the unit people think in ("$500", "60%").
  • Use marks for meaningful stops only.

Don't

  • Don't use a slider for a value that must be exact; offer a text field too.
  • Don't hide the current value when it matters; turn on showValue.

For AI agents

This page as markdown, rendered from the same registry entry. Point an agent at it (or add .md to this page's URL), or at /llms.txt for the index.

Open slider.md

Related: meter, text-input