Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Slider examples · Range

Basic Range Slider for React

A two-thumb slider for picking a range, starting at 25 and 75.

Framework
UI library

Two thumbs pick both ends of a range. Passing two numbers as the default draws two thumbs, and the filled stretch between them is the selection. Use it for price, age or time ranges where both ends are the user's choice.

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 this demo get two thumbs?

The default value is [25, 75], two numbers, so the slider draws one thumb for each. The thumbs keep their order as they move.

What range does it cover?

0 to 100 in steps of 1. min and max set the ends.

Can the thumbs meet?

Yes. No minimum gap is set, so both thumbs can sit on the same value. minStepsBetweenValues keeps them apart.

How are the thumbs named?

The Select Range text is a visible Label, and aria-label names the slider. On Base UI, aria-label is one string, Range.

How do I read the two ends?

The slider keeps its own value here. Make it controlled to read value[0] and value[1], as the Price Range example does.

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.