Skip to content
Cynosurev0.5.0
SearchStorybookGitHubnpmColour mode: System. Switch to Light

Components / Structure

ZoomControls

Zoom out, the current percent with a menu of choices, and zoom in.

Steps and amenu

When to useLink to "When to use"

  • Beside a zoomable view, such as a DocumentViewport, so zoom does not depend on a wheel or a pinch.

UsageLink to "Usage"

tsx
Copy
<ZoomControls zoom={zoom} percent={scale * 100} onZoomChange={setZoom} />

Pass the percent the view came to (DocumentViewport's onScaleChange times 100): fit modes depend on the viewport, so only the view knows it.

Drives adocument viewport

PropsLink to "Props"

Every prop of ZoomControls
PropWhat it doesTypeDefault
zoomRequired
The setting now (fit or a percent).ZoomSetting
percentRequired
The percent it comes to now (DocumentViewport's onScaleChange times 100): shown, and stepped from.number
onZoomChangeRequired
Called with the new setting when the person zooms in or out, or picks one from the menu.(zoom: ZoomSetting) => void
min
The smallest percent zoom out goes to (a PanZoomCanvas's min). Default 25.number25
max
The largest percent zoom in goes to (a PanZoomCanvas's max). Default 800.number800
presets
The percents offered in the menu (those between min and max). Default 50, 75, 100, 125, 150, 200, 400.number[]50
size
Size of the three buttons. Default "sm".Size"sm"
labels
Replace the built-in English text: the names of the toolbar, the buttons and the fit modes.Partial<ZoomControlsLabels>
className
Added to the toolbar element, for layout.string
style
Layout only.CSSProperties

Generated from the type definitions in @arshad-shah/cynosure 0.5.0.

Behaviour and accessibilityLink to "Behaviour and accessibility"

  • Role: a toolbar named "Zoom": one tab stop; Left and Right move between zoom out, the menu and zoom in.
  • Menu: fit width, fit page and preset percents as a radio set; the current one is checked, and choosing closes the menu.
  • Limits: zoom in stops at 800% and zoom out at 25% (the buttons disable); give min and max for a view with other limits (a PanZoomCanvas at 20 to 300%). The menu offers only presets between them.
  • Touch: 44px hit areas on touch screens.

DocumentViewport · Toolbar · Menu

These examples run Cynosure 0.5.0 (commit 50ce30b), the version on npm.

Getting started
Theming
Icons
Accessibility
Code editors and highlighters
Using Cynosure without React
Build-tool adapters
Components
Accordion
AppShell
AspectRatio
Breadcrumbs
Calendar
Card
Container
Disclosure
Divider
DocumentViewport
Grid
Inline
PageHeader
PanZoomCanvas
ScrollArea
SideNav
SortableList
SplitPane
Stack
StatusBar
Tabs
TitleBar
Toolbar
Tree
VirtualList
ZoomControls
Announcer
Avatar
Badge
CodeBlock
DescriptionList
EmptyState
ErrorBoundary
Field
Heading
IconTile
Image
Kbd
List
LoadingDots
Notice
ProgressBar
Prose
Skeleton
Stat
Steps
Table
Text
Button
Checkbox
Checklist
ColorField
ColorSwatches
Combobox
CompareSlider
CopyButton
DateField
FileDrop
IconButton
KeyValueEditor
Link
NumberField
Pagination
PathField
RadioGroup
SearchField
SegmentedControl
Select
SelectionFrame
SignaturePad
Slider
Switch
TagInput
TextArea
TextField
ThemeToggle
TimeField
ButtonBase
ChoiceBase
DialogBase
FileInputBase
HiddenValue
Icon
InputBase
LinkBase
LiveRegion
TextAreaBase
ChatMessage
Choice
DataGrid
DeviceFrame
HighlightedText
HotkeyField
ListRow
OptionList
OverlayFrame
QRCode
RowActions
Section
SiteFooter
SiteHeader
SkipLink
SortButton
VisuallyHidden
CommandPalette
ContextMenu
Dialog
FloatingToolbar
HoverCard
Menu
Menubar
Popover
ProgressOverlay
Sheet
Toast
Tooltip
Changelog