Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Slider examples · Range

Percentage Range Slider for React

A two-thumb percentage slider that steps by 5, with the range beside the label and 0% and 100% under the ends.

Framework
UI library

A range in percent, moving in steps of 5. The selected range sits beside the label, and the ends of the scale sit under the track. Use it for thresholds or a share of a total.

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 does the readout follow the thumb?

The value lives in state, starting at [10, 90], and goes back to the slider as value. The text beside the label prints both values with % signs. onValueChange receives the new value, and the handler stores it as an array.

How does it step?

step is 5, so both thumbs land on multiples of 5.

What range does it cover?

0 to 100, so the values read as percentages. min and max set the ends.

What are the labels under the track?

0% and 100% in a justify-between row, plain muted text that marks the ends.

How are the thumbs named?

Percentage Range is a visible Label. On Base UI, aria-label names the slider Percentage range.

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.