Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Slider examples · Standard

Slider with Step Indicators for React

A Level slider that snaps in steps of 25, with every step labeled under the track.

Framework
UI library

When only a few values are allowed, show them. The slider snaps to 0, 25, 50, 75 and 100, and each stop is labeled under the track. Use it for levels or presets where in-between values mean nothing.

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 it snap?

step is 25, so the thumb only lands on the five stops. The arrow keys move one stop at a time.

How are the stops labeled?

A flex justify-between row of five w-6 spans: the first aligned to the start, the middle three centered and the last to the end, so they sit under the stops.

How does the readout follow the thumb?

The value lives in state, starting at 50, and goes back to the slider as value. The number beside the Level label prints it. onValueChange receives the new value, and the handler stores it as an array.

How is the slider named?

The Level text is a visible Label, and the slider gets the same name with aria-label, so screen readers announce what it sets. On Base UI, aria-label is one string on the slider.

What range does it cover?

0 to 100. min and max set the ends.

Can the slider draw its own marks?

Here the labels are plain text under the track, so they look the same on every target.