Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Slider examples · Interactive

With Live Preview Slider for React

A Border Radius slider from 0 to 50px that rounds a preview box as it moves.

Framework
UI library

Showing the effect beats showing the number. The slider sets a border radius from 0 to 50px, and the box under it is redrawn with that radius as you drag. Use it in editors and design 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 does the box change?

Its inline style sets borderRadius to the value in pixels. transition-all smooths the change.

How does the readout follow the thumb?

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

What range does it cover?

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

What is the preview box?

A div with h-24 and bg-muted-foreground, under the slider in the same column.

How is the slider named?

The Border Radius 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.

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.