Captain UI

Slider

Grab anywhere on the track and it follows your finger 1:1. Pull past an end and the track squashes like rubber; let go and it springs to the nearest step.

npx shadcn@latest add https://captain-ui.vercel.app/r/slider.json
Agents in parallel4 agents
Spend cap per run$12.50
Agents may merge09:00 to 17:30

Worst case today: $50.00 if all 4 hit the cap.

Usage

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

<Slider label="Spend cap per run" defaultValue={[12.5]} max={50} step={2.5} format={(v) => `$${v.toFixed(2)}`} />
<Slider label="Agents may merge" defaultValue={[9, 17.5]} min={6} max={22} step={0.5} />

Props

PropTypeDefaultWhat it does
valuenumber[]Controlled. One value, or two for a range.
defaultValuenumber[][min]Initial value when uncontrolled.
onValueChange(value: number[]) => voidCalled each time the value steps.
onValueCommit(value: number[]) => voidCalled when a drag or key press ends.
min / max / stepnumber0 / 100 / 1The scale. Decimal steps are kept exact.
minStepsBetweenThumbsnumber0Range only: how close the thumbs may get.
ticksbooleanfalseMarks each step on the track, up to 40.
labelReactNodeShown above the track with the live readout.
format(value: number) => stringStringFormats the readout and aria-valuetext.
thumbLabelsstring[]Names for each thumb, read by screen readers.
disabledbooleanDims and ignores input.

Keyboard

← →
One step
Shift + ← →
Ten steps
Page Up / Down
Ten steps
Home / End
Minimum / maximum

Accessibility

  • Each thumb is role=slider with aria-valuenow, aria-valuetext and its own bounds.
  • Range thumbs cannot cross; their min and max follow each other.
  • Pressing the track focuses the thumb it moves, so the keyboard carries on from there.