Dot Slider
A slider made of square dots that light up column by column, swelling as the fill moves forward, with an optional tick per column.
Installation
pnpm dlx shadcn@latest add @breeze/dot-sliderUsage
import { DotSlider } from "@/components/breeze/dot-slider"<DotSlider label="Volume" defaultValue={64} suffix="%" />Click anywhere in the tray to jump there, or drag to scrub. Arrow keys step through values (Shift for 10x), and Home and End jump to the ends.
Motion
As the fill moves forward, each newly lit column swells and settles, so a drag leaves a small wave behind its front; going back it just dims. The leading column grows a little while you hover, drag or focus, so it reads as the thumb, and on hover a dim column previews where a click would land. With reduced motion there's no swell.
Sound
Add sound for a soft tick each time the fill crosses a column. It's generated with WebAudio, so there's no file to ship, and it starts after the first interaction, as browsers require.
Examples
Settings
"use client"
import { useState } from "react"
import { DotSlider } from "@/components/breeze/dot-slider"
export function Settings() {
const [volume, setVolume] = useState(64)
const [warmth, setWarmth] = useState(35)
const [speed, setSpeed] = useState(1.2)
return (
<div className="flex w-full max-w-md flex-col gap-6">
<DotSlider label="Volume" value={volume} onChange={setVolume} suffix="%" sound />
<DotSlider
label="Warmth"
value={warmth}
onChange={setWarmth}
color="#f97316"
formatValue={(v) => `${Math.round(2700 + (v / 100) * 3800)}K`}
/>
<DotSlider
label="Speed"
value={speed}
onChange={setSpeed}
min={0.25}
max={3}
step={0.05}
color="#8b5cf6"
rows={2}
suffix="x"
/>
</div>
)
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | ReactNode | Shown above the tray with the value; also the accessible name | |
value | number | Controlled value | |
defaultValue | number | 50 | Starting value when uncontrolled |
onChange | (value: number) => void | Called with each new value | |
min | number | 0 | Lowest value |
max | number | 100 | Highest value |
step | number | 1 | Value increment |
color | string | "var(--brand)" | Lit dot colour, any CSS colour or var() |
rows | number | 3 | Rows of dots |
dotSize | number | 4 | Dot size in px |
gap | number | 4 | Space between dots in px |
suffix | string | "" | Text after the value, e.g. "%" |
formatValue | (value: number) => ReactNode | Custom value text | |
sound | boolean | false | A soft tick per column |
disabled | boolean | false | Dims it and ignores input |