Components
Gradient Slider
A slider over a colour gradient track.
<GradientSlider label="Temperature" colors={["#3b82f6", "#ef4444"]} min={16} />Installation
npx shadcn@latest add https://ui.zjkm.tech/r/gradient-slider.jsonimport { GradientSlider } from "@/components/gradient-slider"Using JavaScript? Set tsx: false in components.json and the CLI converts it.
New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.
Usage
A slider over a colour gradient, for settings that are a scale rather than a number: temperature, warmth, intensity.
import { GradientSlider } from "@/components/gradient-slider";
export function Thermostat() {
return <GradientSlider label="Temperature" colors={["#3b82f6", "#ef4444"]} min={16} max={30} format={(v) => `${v}°C`} />;
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | The label. | |
colors | string[] | blue, purple, red | The track's colours, left to right. |
defaultValue | number | 50 | Starting value. |
min | number | 0 | Lowest value. |
max | number | 100 | Highest value. |
step | number | 1 | Step between values. |
format | (value: number) => string | String | Turns the value into the text shown and read out, e.g. v => `${v}%`. |
onChange | (value: number) => void | Called as the value changes. | |
className | string | Classes for the wrapper. |
It has no animation, so reduced motion changes nothing.