Line SliderPro

Usage

Pass value and onValueChange to control it. Double-click resets to defaultValue.

Example
const [volume, setVolume] = useState(40)

<LineSlider label="Volume" value={volume} onValueChange={setVolume} />

variant="track" keeps dim lines on the empty part and fills them in place.

Example
<LineSlider label="Brightness" variant="track" defaultValue={75} />

gap sets the space between lines and fits as many as the width allows.

Example
<LineSlider label="Volume" gap={4} lineWidth={3} bordered />

Tune the motion; the defaults are exported as LINE_SLIDER_MOTION.

Example
<LineSlider label="Volume" stiffness={600} damping={1} travel={40} blur={1} />

onValueCommit fires once when a drag ends. Sparks show at the max and min; sparks={false} turns them off.

Example
<LineSlider label="Volume" onValueCommit={saveVolume} sparks={false} />

sound adds a soft tick per line, rising as it fills, with a chime at the max. Off by default.

Example
<LineSlider label="Volume" sound />

Props

PropTypeDefaultNotes
labelstring—Text above the track, linked to the input.
valuenumber—Controlled value. Leave unset for the slider to keep its own.
defaultValuenumberminStarting value, and what double-click resets to.
onValueChange(value: number) => void—Fires on every change.
onValueCommit(value: number) => void—Fires once when a drag, key press or double-click reset finishes.
minnumber0
maxnumber100
stepnumber1
linesnumber64How many lines make up the track.
gapnumber—px between lines. When set, as many lines as fit the width are drawn and lines is ignored.
lineWidthnumber2px width of each line, rounded to whole screen pixels.
borderedbooleanfalseDraw a rounded outline around the whole bar.
accentstring"#3f7bff"Colour of the filled lines.
variant"reveal" | "track""reveal"Dots with lines that fly off, or dim lines that fill and empty in place.
sparksbooleantrueGolden sparks at the max, a dull star at the min.
soundbooleanfalseSoft ticks as lines fill or empty, a chime at the max and a thud at the min.
stiffnessnumber400How hard the fill edge pulls toward the value. Higher sweeps faster.
dampingnumber0.851 arrives without overshooting; lower overshoots and settles back. Keep it 0.7 or above for a direct-feeling slider.
enterDurationnumber60ms for a line to catch up with the edge when filling.
exitDurationnumber90ms for a line to catch up with the edge when emptying.
travelnumber25How far a leaving line drifts up or down, in % of its height. reveal only.
blurnumber1.5px of blur on a leaving line at its furthest. reveal only.
format(value: number) => stringup to 2 decimalsHow the value is shown and read out.
showValuebooleantrueShow the value beside the label.
disabledbooleanfalse
namestring—Submitted with a form.

Accessibility

  • A native input type="range" sits over the track, so arrow keys, Page Up/Down, Home/End and screen readers all work as with any slider
  • aria-valuetext reads the formatted value
  • A ring shows around the track while it has keyboard focus
  • With reduced motion on, lines and stars only fade, without moving