Gradient Track Slider
Original · freeslider with a gradient track
byWeb InnoventixReact + Tailwind
sldgradienttracksliders
Copy prompt gives Claude Code, Cursor or v0 a ready-to-paste prompt that recreates this exact component.
npx shadcn@latest add https://webinnoventix.com/r/sld-gradient-track.jsonsld-gradient-track.tsx
"use client";
import { useState } from "react";
import type { CSSProperties } from "react";
import { motion, useReducedMotion } from "motion/react";
type CSSVars = CSSProperties & Record<`--${string}`, string>;
type SliderId = "temp" | "tint" | "sat" | "exposure";
interface Stop {
at: number;
rgb: [number, number, number];
}
interface SliderDef {
id: SliderId;
label: string;
hint: string;
gradient: string;
stops: Stop[];
ends: [string, string];
descriptor: (v: number) => string;
}
interface Preset {
id: string;
name: string;
values: Record<SliderId, number>;
}
const MIN = -100;
const MAX = 100;
const THUMB = 22;
const SLIDERS: SliderDef[] = [
{
id: "temp",
label: "Temperature",
hint: "white balance",
gradient: "linear-gradient(90deg, #3b82f6 0%, #e2e8f0 50%, #f59e0b 100%)",
stops: [
{ at: 0, rgb: [59, 130, 246] },
{ at: 0.5, rgb: [226, 232, 240] },
{ at: 1, rgb: [245, 158, 11] },
],
ends: ["Cool", "Warm"],
descriptor: (v) =>
v === 0 ? "neutral" : v > 0 ? (v > 60 ? "hot" : "warm") : v < -60 ? "icy" : "cool",
},
{
id: "tint",
label: "Tint",
hint: "green / magenta",
gradient: "linear-gradient(90deg, #10b981 0%, #e2e8f0 50%, #ec4899 100%)",
stops: [
{ at: 0, rgb: [16, 185, 129] },
{ at: 0.5, rgb: [226, 232, 240] },
{ at: 1, rgb: [236, 72, 153] },
],
ends: ["Green", "Magenta"],
descriptor: (v) => (v === 0 ? "neutral" : v > 0 ? "magenta" : "green"),
},
{
id: "sat",
label: "Saturation",
hint: "muted / vivid",
gradient: "linear-gradient(90deg, #94a3b8 0%, #818cf8 50%, #7c3aed 100%)",
stops: [
{ at: 0, rgb: [148, 163, 184] },
{ at: 0.5, rgb: [129, 140, 248] },
{ at: 1, rgb: [124, 58, 237] },
],
ends: ["Muted", "Vivid"],
descriptor: (v) =>
v <= -100 ? "grayscale" : v === 0 ? "normal" : v > 0 ? "vivid" : "muted",
},
{
id: "exposure",
label: "Exposure",
hint: "shadow / highlight",
gradient: "linear-gradient(90deg, #171717 0%, #787878 50%, #fafafa 100%)",
stops: [
{ at: 0, rgb: [23, 23, 23] },
{ at: 0.5, rgb: [120, 120, 120] },
{ at: 1, rgb: [250, 250, 250] },
],
ends: ["Shadow", "Highlight"],
descriptor: (v) => (v === 0 ? "neutral" : v > 0 ? "brighter" : "darker"),
},
];
const PRESETS: Preset[] = [
{ id: "neutral", name: "Neutral", values: { temp: 0, tint: 0, sat: 0, exposure: 0 } },
{ id: "golden", name: "Golden Hour", values: { temp: 58, tint: 10, sat: 20, exposure: 8 } },
{ id: "arctic", name: "Arctic", values: { temp: -46, tint: -8, sat: -10, exposure: 12 } },
{ id: "vintage", name: "Vintage", values: { temp: 24, tint: 16, sat: -32, exposure: -6 } },
{ id: "noir", name: "Noir", values: { temp: -4, tint: 0, sat: -100, exposure: -10 } },
];
const SCENE =
"radial-gradient(130% 90% at 18% 12%, rgba(254,240,138,0.95), rgba(254,240,138,0) 55%)," +
"radial-gradient(120% 100% at 85% 15%, rgba(244,114,182,0.85), rgba(244,114,182,0) 50%)," +
"radial-gradient(140% 120% at 50% 120%, rgba(16,185,129,0.85), rgba(16,185,129,0) 55%)," +
"linear-gradient(150deg, #4f46e5 0%, #0ea5e9 42%, #14b8a6 78%, #f59e0b 100%)";
const EASE = [0.22, 1, 0.36, 1] as const;
function clamp255(n: number): number {
return Math.max(0, Math.min(255, Math.round(n)));
}
function sampleStops(stops: Stop[], t: number): string {
const c = Math.min(1, Math.max(0, t));
for (let i = 0; i < stops.length - 1; i++) {
const a = stops[i];
const b = stops[i + 1];
if (c >= a.at && c <= b.at) {
const span = b.at - a.at || 1;
const lt = (c - a.at) / span;
const r = Math.round(a.rgb[0] + (b.rgb[0] - a.rgb[0]) * lt);
const g = Math.round(a.rgb[1] + (b.rgb[1] - a.rgb[1]) * lt);
const bl = Math.round(a.rgb[2] + (b.rgb[2] - a.rgb[2]) * lt);
return `rgb(${r}, ${g}, ${bl})`;
}
}
const last = stops[stops.length - 1].rgb;
return `rgb(${last[0]}, ${last[1]}, ${last[2]})`;
}
function signed(v: number): string {
return v > 0 ? `+${v}` : `${v}`;
}
export default function GradientTrackSlider() {
const prefersReduced = useReducedMotion();
const reduce = prefersReduced === true;
const [values, setValues] = useState<Record<SliderId, number>>({
temp: 0,
tint: 0,
sat: 0,
exposure: 0,
});
const [activePreset, setActivePreset] = useState<string | null>("neutral");
function update(id: SliderId, next: number) {
setValues((prev) => ({ ...prev, [id]: next }));
setActivePreset(null);
}
function applyPreset(p: Preset) {
setValues(p.values);
setActivePreset(p.id);
}
const warmth = values.temp / 100;
const tn = values.tint / 100;
const castR = clamp255(128 + warmth * 95 + tn * 45);
const castG = clamp255(128 - tn * 55 - Math.abs(warmth) * 4);
const castB = clamp255(128 - warmth * 95 + tn * 45);
const castRgb = `rgb(${castR}, ${castG}, ${castB})`;
const washOpacity = Math.min(0.7, (Math.abs(warmth) + Math.abs(tn)) * 0.55);
const sceneFilter =
`saturate(${(1 + values.sat / 100).toFixed(2)}) ` +
`brightness(${(1 + values.exposure / 160).toFixed(2)}) ` +
`contrast(${(1 + Math.abs(values.exposure) / 400).toFixed(2)})`;
const lookName = activePreset
? PRESETS.find((p) => p.id === activePreset)?.name ?? "Custom"
: "Custom";
const reveal = (delay: number) => ({
initial: reduce ? false : { opacity: 0, y: 12 },
animate: { opacity: 1, y: 0 },
transition: { duration: 0.5, ease: EASE, delay: reduce ? 0 : delay },
});
return (
<section className="relative w-full overflow-hidden bg-slate-50 px-5 py-16 text-slate-900 dark:bg-zinc-950 dark:text-slate-100 sm:px-8 sm:py-24">
<style>{`
.sgt-range {
-webkit-appearance: none;
appearance: none;
width: 100%;
height: 24px;
background: transparent;
cursor: pointer;
}
.sgt-range:focus { outline: none; }
.sgt-range::-webkit-slider-runnable-track {
height: 12px;
border-radius: 999px;
background: var(--sgt-grad);
box-shadow: inset 0 1px 2px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(255,255,255,0.14);
}
.sgt-range::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 22px;
height: 22px;
margin-top: -5px;
border-radius: 999px;
background: var(--sgt-thumb);
border: 3px solid #ffffff;
box-shadow: 0 2px 6px rgba(0,0,0,0.35), 0 0 0 1px rgba(0,0,0,0.18);
transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.sgt-range:active::-webkit-slider-thumb { transform: scale(1.14); }
.sgt-range:focus-visible::-webkit-slider-thumb {
box-shadow: 0 0 0 4px rgba(99,102,241,0.55), 0 2px 6px rgba(0,0,0,0.35);
}
.sgt-range::-moz-range-track {
height: 12px;
border-radius: 999px;
background: var(--sgt-grad);
box-shadow: inset 0 1px 2px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(255,255,255,0.14);
}
.sgt-range::-moz-range-thumb {
width: 22px;
height: 22px;
border-radius: 999px;
background: var(--sgt-thumb);
border: 3px solid #ffffff;
box-shadow: 0 2px 6px rgba(0,0,0,0.35), 0 0 0 1px rgba(0,0,0,0.18);
transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.sgt-range:active::-moz-range-thumb { transform: scale(1.14); }
.sgt-range:focus-visible::-moz-range-thumb {
box-shadow: 0 0 0 4px rgba(99,102,241,0.55), 0 2px 6px rgba(0,0,0,0.35);
}
@keyframes sgtc-sheen {
0% { transform: translateX(-130%) skewX(-16deg); }
100% { transform: translateX(230%) skewX(-16deg); }
}
.sgtc-sheen { animation: sgtc-sheen 7s linear infinite; }
@media (prefers-reduced-motion: reduce) {
.sgtc-sheen { animation: none; }
.sgt-range::-webkit-slider-thumb { transition: none; }
.sgt-range::-moz-range-thumb { transition: none; }
}
`}</style>
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0"
style={{
background:
"radial-gradient(48% 40% at 12% 8%, rgba(99,102,241,0.16), transparent 70%)," +
"radial-gradient(46% 44% at 90% 100%, rgba(236,72,153,0.14), transparent 70%)",
}}
/>
<div className="relative mx-auto w-full max-w-3xl">
<motion.header {...reveal(0)} className="mb-8 sm:mb-10">
<div className="flex items-center gap-2.5">
<span className="flex h-8 w-8 items-center justify-center rounded-lg bg-slate-900 text-white dark:bg-white dark:text-slate-900">
<svg viewBox="0 0 24 24" className="h-4 w-4" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" aria-hidden="true">
<path d="M4 7h9" />
<path d="M17 7h3" />
<circle cx="15" cy="7" r="2" />
<path d="M4 17h3" />
<path d="M11 17h9" />
<circle cx="9" cy="17" r="2" />
</svg>
</span>
<span className="font-mono text-[11px] font-medium uppercase tracking-[0.22em] text-slate-500 dark:text-slate-400">
Color Grade · v2
</span>
</div>
<h2 className="mt-4 font-serif text-3xl font-semibold tracking-tight text-slate-900 dark:text-white sm:text-4xl">
Grade the frame.
</h2>
<p className="mt-2 max-w-lg text-sm leading-relaxed text-slate-600 dark:text-slate-400">
Four gradient tracks, one live look. Drag, or steer with the arrow keys — every
track shows exactly what it does to the picture.
</p>
</motion.header>
<div className="rounded-3xl border border-slate-200/80 bg-white/85 p-4 shadow-xl shadow-slate-900/5 backdrop-blur-sm dark:border-zinc-800 dark:bg-zinc-900/70 dark:shadow-black/40 sm:p-6">
<div className="grid gap-6 lg:grid-cols-[1.05fr_1fr] lg:gap-8">
<motion.div {...reveal(0.06)} className="min-h-[260px]">
<div className="relative h-full min-h-[240px] overflow-hidden rounded-2xl border border-slate-200/70 dark:border-zinc-800">
<div
className="absolute inset-0 transition-[filter] duration-200 ease-out"
style={{ background: SCENE, filter: sceneFilter }}
/>
<div
aria-hidden="true"
className="absolute inset-0 transition-opacity duration-200 ease-out"
style={{
background: castRgb,
opacity: washOpacity,
mixBlendMode: "soft-light",
}}
/>
<div className="pointer-events-none absolute inset-0 overflow-hidden">
<div
aria-hidden="true"
className="sgtc-sheen absolute -inset-y-4 left-0 w-1/4"
style={{
background:
"linear-gradient(90deg, transparent, rgba(255,255,255,0.28), transparent)",
}}
/>
</div>
<div
aria-hidden="true"
className="absolute inset-x-0 bottom-0 h-24"
style={{
background: "linear-gradient(to top, rgba(0,0,0,0.55), transparent)",
}}
/>
<div className="absolute inset-x-0 bottom-0 flex items-end justify-between gap-3 p-4">
<div>
<p className="font-mono text-[10px] uppercase tracking-[0.24em] text-white/70">
Live preview
</p>
<p className="mt-0.5 font-serif text-lg font-medium text-white">
{lookName}
</p>
</div>
<div className="flex items-center gap-2 rounded-full bg-black/35 px-2.5 py-1.5 backdrop-blur-sm">
<span
className="h-4 w-4 rounded-full ring-1 ring-white/40"
style={{ background: castRgb }}
/>
<span className="font-mono text-[11px] text-white/85">cast</span>
</div>
</div>
</div>
</motion.div>
<div className="flex flex-col">
<motion.div {...reveal(0.12)} className="mb-5">
<div className="mb-2.5 flex items-baseline justify-between">
<span className="font-mono text-[11px] font-medium uppercase tracking-[0.18em] text-slate-500 dark:text-slate-400">
Looks
</span>
<span className="font-mono text-[11px] text-slate-400 dark:text-slate-500">
{activePreset ? "preset" : "custom"}
</span>
</div>
<div className="flex flex-wrap gap-2">
{PRESETS.map((p) => {
const on = activePreset === p.id;
return (
<button
key={p.id}
type="button"
aria-pressed={on}
onClick={() => applyPreset(p)}
className={
"rounded-full border px-3 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-2 focus-visible:ring-offset-white dark:focus-visible:ring-offset-zinc-900 " +
(on
? "border-transparent bg-slate-900 text-white dark:bg-white dark:text-slate-900"
: "border-slate-200 bg-slate-50 text-slate-600 hover:border-slate-300 hover:bg-slate-100 dark:border-zinc-700 dark:bg-zinc-800/60 dark:text-slate-300 dark:hover:border-zinc-600 dark:hover:bg-zinc-800")
}
>
{p.name}
</button>
);
})}
</div>
</motion.div>
<ul className="space-y-6">
{SLIDERS.map((def, i) => {
const v = values[def.id];
const t = (v - MIN) / (MAX - MIN);
const thumb = sampleStops(def.stops, t);
const trackStyle: CSSVars = {
"--sgt-grad": def.gradient,
"--sgt-thumb": thumb,
};
return (
<motion.li key={def.id} {...reveal(0.18 + i * 0.06)}>
<div className="flex items-baseline justify-between gap-3">
<label
htmlFor={`sgt-${def.id}`}
className="flex items-baseline gap-2 text-sm font-medium text-slate-800 dark:text-slate-100"
>
{def.label}
<span className="font-mono text-[10px] font-normal uppercase tracking-wide text-slate-400 dark:text-slate-500">
{def.hint}
</span>
</label>
<span className="font-mono text-sm tabular-nums text-slate-900 dark:text-white">
{signed(v)}
<span className="ml-1.5 text-xs text-slate-400 dark:text-slate-500">
{def.descriptor(v)}
</span>
</span>
</div>
<div className="group relative mt-3">
<div
aria-hidden="true"
className="pointer-events-none absolute -top-9 z-10 -translate-x-1/2 translate-y-1 rounded-md bg-slate-900 px-2 py-1 font-mono text-[11px] tabular-nums text-white opacity-0 shadow-lg transition duration-150 group-hover:translate-y-0 group-hover:opacity-100 group-focus-within:translate-y-0 group-focus-within:opacity-100 dark:bg-white dark:text-slate-900"
style={{ left: `calc(11px + ${t} * (100% - ${THUMB}px))` }}
>
{signed(v)}
</div>
<input
id={`sgt-${def.id}`}
type="range"
className="sgt-range"
min={MIN}
max={MAX}
step={1}
value={v}
style={trackStyle}
onChange={(e) => update(def.id, Number(e.currentTarget.value))}
aria-valuetext={`${signed(v)}, ${def.descriptor(v)}`}
/>
</div>
<div className="mt-1.5 grid grid-cols-3 font-mono text-[10px] uppercase tracking-wide text-slate-400 dark:text-slate-500">
<span className="text-left">{def.ends[0]}</span>
<span className="text-center">0</span>
<span className="text-right">{def.ends[1]}</span>
</div>
</motion.li>
);
})}
</ul>
<motion.div
{...reveal(0.18 + SLIDERS.length * 0.06)}
className="mt-7 flex items-center justify-between gap-3 border-t border-slate-200 pt-4 dark:border-zinc-800"
>
<p className="min-w-0 truncate font-mono text-[11px] text-slate-500 dark:text-slate-400">
T {signed(values.temp)} · Ti {signed(values.tint)} · S {signed(values.sat)}{" "}
· E {signed(values.exposure)}
</p>
<button
type="button"
onClick={() => applyPreset(PRESETS[0])}
className="inline-flex shrink-0 items-center gap-1.5 rounded-full border border-slate-200 bg-white px-3 py-1.5 text-xs font-medium text-slate-700 transition-colors hover:bg-slate-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-2 focus-visible:ring-offset-white dark:border-zinc-700 dark:bg-zinc-800/60 dark:text-slate-200 dark:hover:bg-zinc-800 dark:focus-visible:ring-offset-zinc-900"
>
<svg viewBox="0 0 24 24" className="h-3.5 w-3.5" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
<path d="M3 12a9 9 0 1 0 3-6.7" />
<path d="M3 4v4h4" />
</svg>
Reset
</button>
</motion.div>
</div>
</div>
</div>
</div>
</section>
);
}Dependencies
motion
Licence
Built by Web Innoventix. Free for personal and commercial use, no attribution required.
Built by Web Innoventix
Need a custom interface, a full website, or SEO that gets you cited by AI? We design, build and rank it end to end.
Get a free quoteSimilar components
Browse all →
Basic Slider
Originalbasic range slider with value bubble

Range Dual Slider
Originaldual-handle min/max range

Steps Slider
Originalstepped slider with tick marks

Vertical Slider
Originalvertical sliders

Tooltip Slider
Originalslider with a floating value tooltip

Volume Slider
Originalvolume slider with icon

Price Range Slider
Originalprice range filter slider

Rating Slider
Originalsatisfaction rating slider

Brightness Slider
Originalbrightness/contrast control sliders

Marks Slider
Originalslider with labelled marks

Color Hue Slider
Originalhue/saturation color sliders

Progress Drag Slider
Originalmedia scrubber slider

