Temperature Slider
Sleek temperature slider with animated number flow and frosted glass track.
Category
SliderReact
CSS
shadcnCustom CSS
Manual
Create a file and paste the following code into it.
src/slider-demo.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { useState } from "react";
import NumberFlow from "@number-flow/react";
import { Slider } from "@/components/ui/slider";
function SliderDemo() {
const [value, setValue] = useState<number[]>([28.1]);
return (
<div className="flex h-dvh w-full items-center justify-center bg-[#ededed] px-6">
<section className="w-full">
<div className="mb-2 flex items-end justify-between">
<h2 className="text-xl font-semibold tracking-tight text-black">
Temperature
</h2>
<NumberFlow
value={value[0]}
className="text-xl font-medium text-black/45"
format={{ minimumFractionDigits: 1, maximumFractionDigits: 1 }}
suffix="%"
/>
</div>
<Slider
variant="temperature"
value={value}
onValueChange={setValue}
min={0}
max={100}
step={0.1}
aria-label="Temperature"
/>
</section>
</div>
);
}
export default SliderDemo;Update the import paths to match your project setup.