Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Slider examples · Settings

Temperature Control Slider for React

A Temperature slider from 16°C to 30°C on a cool-to-hot gradient track, with the reading beside the label.

Framework
UI library

A thermostat-style control. The track fades from a cool color to a hot one, the reading sits beside the label, and the ends are written under the track. Use it for climate or heating settings.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

How is the gradient drawn?

On the track: the slider's class gives the part with data-slot="slider-track" a bg-linear-to-r from info to destructive, and makes the range transparent so the gradient shows.

How does the readout follow the thumb?

The value lives in state, starting at 22, and goes back to the slider as value. The reading beside the label prints it with °C. onValueChange receives the new value, and the handler stores it as an array.

What range does it cover?

16 to 30 in steps of 1, and the labels under the track repeat those ends. min and max set the ends.

Is the thermometer icon announced?

No. It has aria-hidden="true"; the label and the slider's aria-label say Temperature.

Can it move in half degrees?

Set step to 0.5. The demo uses whole degrees.

When should I save the temperature?

The change callback runs on every step while the thumb moves. Save or fetch from the end-of-change callback, which runs once when dragging stops. On Base UI it is onValueCommitted.