shadcn.io is not affiliated with official shadcn/ui
Slider examples · Settings
Volume Control Slider for React
A Volume slider with a speaker icon and its percentage beside the label.
Framework
UI library
The familiar volume control: a speaker icon, a label and the level as a percentage. It starts at 65. Use it in media players and sound settings.
Preview
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 65, and goes back to the slider as value. The percentage beside the label prints it.
onValueChange receives the new value, and the handler stores it as an array.
Is the speaker icon announced?
No. It has aria-hidden="true"; the Volume label and the slider's aria-label name the control.
How do I add a mute button?
Put a Button with the icon before the slider and set the value to 0 on click, keeping the last level to restore. The demo has no mute.
Related
- Brightness Control SliderA Brightness slider with a sun icon, a
- Temperature Control SliderA Temperature slider from 16°C to 30°C on
- Speed Control SliderA Speed slider with four steps, from Slow
- Slider with LabelA slider with a Volume label above the
- Percentage Range SliderA two-thumb percentage slider that steps
- Synced with Input Field SliderA slider and a number field that share