shadcn.io is not affiliated with official shadcn/ui
Button Group examples · Media
Zoom Controls Button Group for React
Zoom controls that step from 25% to 400% in 25% steps, with Reset and Fit buttons and a row showing the zoom level.
Zoom for an image viewer or a document. Zoom out and zoom in step by 25%, clamped between 25% and 400%; Reset and Fit both return to 100%. The second row shows the current level between the two icon buttons.
Preview
Installation
FAQ
How is the zoom tracked?
As a number, starting at 100. Zoom out subtracts 25 and stops at 25; zoom in adds 25 and stops at 400.
How are the icon-only buttons named?
Zoom out and Zoom in are aria-labels, with size="icon-sm". Reset and Fit have text, and their icons have aria-hidden="true".
Why do Reset and Fit do the same thing?
In the demo both set 100%, since there's no content to measure. Make Fit compute the level that fits your content in its container.
Does the percentage button do anything?
No. It shows the level and has no handler. Make it reset to 100% if you want, or use ButtonGroupText so it doesn't take focus.
Related
- Volume Controls Button GroupVolume controls with a mute toggle and
- Map Controls Button GroupA map layer picker with Satellite, Road
- Quantity Picker Button GroupTwo quantity pickers with minus and plus
- Simple SliderA single-thumb slider with no label or
- Basic Button GroupThree rows of outline buttons joined into
- Playback Speed Button GroupA playback speed picker with rates from