DitherCharts

Slider

Updated

Slider is a native range input over a dithered track. The track fills with ink up to the thumb and fades out through a Bayer ramp, and the value shows beside the label. Like the charts, it takes your theme's ink and paper, light or dark, and needs no Tailwind.

Example

import "@/components/dithercharts/controls.css"
import { Slider } from "@/components/dithercharts/slider"

<Slider label="Opacity" defaultValue={40} />
<Slider label="Cell size" min={1} max={8} defaultValue={3} />
<Slider label="Locked" defaultValue={70} disabled />

Install

Controls install with DitherCharts Pro. See Installation to log in, then import controls.css once, e.g. in your root layout.

npx dithercharts add slider

Props

It renders a native element, so every other attribute that element takes passes through.

Slider props
PropTypeDefaultDescription
labelrequiredType ReactNodeDefault –The caption above the track, and the slider's accessible name.
hideLabelType booleanDefault falseKeeps the label for screen readers only, e.g. when a row caption sits beside the track; the value hides with it.
showValueType booleanDefault trueShows the current value beside the label.
onValueChangeType (value: number) => voidDefault –Called with the new value as the thumb moves.