Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Slider examples · Settings

Speed Control Slider for React

A Speed slider with four steps, from Slow to Very Fast, named beside the label and under the track.

Framework
UI library

Some settings have names, not numbers. The slider runs from 0 to 3, and each step maps to Slow, Normal, Fast or Very Fast. Use it for playback or animation speed.

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 do the steps get names?

A speedLabels array holds the four names. The text beside the label prints the name at the current value, and the row under the track lists all four.

How does the readout follow the thumb?

The value lives in state, starting at 1 (Normal), and goes back to the slider as value. The name beside the label looks it up in speedLabels. onValueChange receives the new value, and the handler stores it as an array.

What range does it cover?

0 to 3 in steps of 1, one step per name. min and max set the ends.

What does a screen reader announce?

The number, 0 to 3, because the slider only knows numbers. The name is in the visible text beside the label.

Is the gauge icon announced?

No. It has aria-hidden="true".

Can I move it from the keyboard?

Yes. The thumb takes focus with Tab. The arrow keys move it by one step, Page Up and Page Down by a larger step, and Home and End jump to the ends.