Skip to content

Slider

Pick a number, or a range between two handles, by dragging along a track. It can show tick marks, and the capsule style puts the label and value inside the bar.

// Radix — @radix-ui/react-slider
import { CapsuleSlider, Slider } from "@shavin/ui";

Capsule variant

Plain smooth bar (no ticks)
Theme Brand with auto stops (step=5)
Monochrome inverting (color="mono")
Component Source
const [brightness, setBrightness] = useState(50);
const [volume, setVolume] = useState(65);
const [speed, setSpeed] = useState(30);

{/* 1. Plain smooth slider bar (continuous / no stop ticks) */}
<Slider
  variant="capsule"
  label="Brightness"
  value={brightness}
  onValueChange={setBrightness}
  min={0}
  max={100}
  step={1}
  showStops={false}
  formatValue={(v) => `${v}%`}
/>

{/* 2. Theme Brand color with discrete stop marks */}
<Slider
  variant="capsule"
  color="brand"
  label="Volume"
  value={volume}
  onValueChange={setVolume}
  min={0}
  max={100}
  step={5}
  marks="auto"
  formatValue={(v) => `${v}%`}
/>

{/* 3. Monochrome inverting color (bg-fg / text-canvas) */}
<Slider
  variant="capsule"
  color="mono"
  label="Speed Factor"
  value={speed}
  onValueChange={setSpeed}
  min={0}
  max={100}
  step={10}
  marks="auto"
  formatValue={(v) => `${(v / 20).toFixed(1)}x`}
/>

Single value (standard track)

40
Component Source
const [value, setValue] = useState(40);

<Slider aria-label="Volume" value={value} onValueChange={setValue} min={0} max={100} step={1} />

Range (two thumbs)

20 – 70
Component Source
const [range, setRange] = useState([20, 70]);

<Slider aria-label="Volume" value={range} onValueChange={setRange} min={0} max={100} step={1} />

Stops (marks="auto" auto-calculated from step)

Auto-calculated ticks (step=20, marks="auto")
40
Milestone marks (step=5, marks=[0, 25, 50, 75, 100])
50
Component Source
const [value, setValue] = useState(40);

{/* marks="auto" automatically renders ticks at each step quantum */}
<Slider aria-label="Volume"
  value={value}
  onValueChange={setValue}
  min={0}
  max={100}
  step={20}
  marks="auto"
/>

{/* Custom milestone marks array: marks={[0, 25, 50, 75, 100]} */}
<Slider aria-label="Volume"
  value={value}
  onValueChange={setValue}
  min={0}
  max={100}
  step={5}
  marks={[0, 25, 50, 75, 100]}
/>

Radius

rounded (radius="full", fixed)
square (radius="none", fixed)
inherit (tracks the Radius Configurator)
Component Source
{/* Explicit — fixed regardless of the Configurator */}
<Slider aria-label="Volume" defaultValue={50} radius="full" />   {/* rounded */}
<Slider aria-label="Volume" defaultValue={50} radius="none" />   {/* square */}
{/* Inherit — tracks the global Radius Configurator */}
<Slider aria-label="Volume" defaultValue={50} radius="inherit" />

Props

PropTypeDefaultDescription
variant"default" | "capsule"—Visual variant: "default" (standard track & thumb) or "capsule" (sleek compact pill with embedded label and live fill value).
valuenumber[] | number—Current value: number[] (e.g. [40]) or single number (e.g. 40).
defaultValuenumber[] | numbervalueDefault value when uncontrolled.
onValueChange(val: any) => void—Value change callback.
marksnumber[] | "auto"—Optional array of numeric tick mark values drawn on the track (e.g. [0, 50, 100]) or "auto" for auto-calculated stops based on step.
labelReactNode—Label text or ReactNode displayed inside capsule slider track (when variant="capsule").
formatValue(val: number) => string—Formatter function for displaying formatted value string in capsule mode (e.g. (v) => `${v}px`).
color"brand" | "mono"brandFill color style in capsule mode: "brand" (active theme brand) or "mono" (monochrome inverting). Default "brand".
showStopsbooleantrueWhether to show subtle stop ticks on hover in capsule mode. Default true for discrete steps (3–30).
radius"none" | "small" | "medium" | "large" | "full" | "inherit" | "concentric""inherit"—
Configure Theme
Theme
Brand Color
Custom
Gray Family
Appearance
Radius
Scaling
Panel Style
Heading Font
Body Font