Image crop
ProFrames a photo before upload: drag, pinch or zoom it behind a fixed frame, and get the crop in the original pixels. Not an M3 component (@windmorph/react-pro).
import { ImageCropDialog, ImageCropper } from '@windmorph/react-pro';Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.
Props
ImageCropDialog 17 props
Whether the dialog is open (controlled).
The photo: an object URL of a picked file, or any image URL.
The frame's width divided by its height.
circledraws a dashed circle in the frame, showing what a round avatar shows.How far the photo can be zoomed past "just covers the frame".
The app is saving after confirm: Save is pending (it keeps focus and announces
labels.pending), Cancel and the full-screen Close are disabled, a progress indicator shows, and the dialog can't be dismissed.Upload progress from 0 to 1 while
pending; indeterminate when left out.Replaces the zoom-in button's icon.
Replaces the zoom-out button's icon.
The dialog panel (the element with
role="dialog"), as the coreDialog'sref.An id for the dialog panel.
Events
Called when the dialog asks to open or close; never to close while
pending.Called with the crop when the person confirms. Keep the dialog open while uploading (
pending).
Text
Every word the dialog shows or announces, from the app's translations. English by default. A
LabelsProvidersets them for the whole app.The dialog's headline, e.g. "Adjust your photo".
The confirming action, e.g. "Save".
The cancelling action.
The full-screen dialog's close button.
Names the progress indicator, and is added to Save's name, while
pending.Names the area that holds the photo.
labels.instructionstypestringdefault"Drag, or use the arrow keys, to move the photo. Use plus and minus to zoom, and 0 to reset."How to move and zoom without a pointer; read by screen readers.
Names the zoom slider.
Names the zoom-in button.
Names the zoom-out button.
Shown when the photo can't be opened.
Goes on the outermost element, the full-window layer around the dialog (as on the core
Dialog), so a layout class never hides or clips it. Style the surface withclassNames.panel.Classes for each part: the dialog's
scrim,panelandcontent, and the cropper's parts (root,area,frame, …).The cropper's outermost element, inside the dialog's content. Unlike on a bare
ImageCropper,classNamedoesn't go here: it goes on the dialog's outermost layer, as on the coreDialog.The dimmed layer behind the dialog (the core
Dialog'sscrim).The dialog's surface (the core
Dialog'spanel).The dialog's content, which holds the progress indicator and the cropper.
The area that holds the photo and takes drags, pinches and keys.
The photo.
The frame: what is kept, with the dimmed photo around it.
The dashed circle in the frame (
guide="circle").The skeleton shown in the frame while the photo loads.
The message shown when the photo can't be opened.
The row with the zoom buttons and slider.
The zoom slider.
The zoom-out button.
The zoom-in button.
Goes on the outermost element, with
className(as on the coreDialog).
ImageCropper 12 props
The photo: an object URL of a picked file, or any image URL.
The frame's width divided by its height.
circledraws a dashed circle in the frame, showing what a round avatar shows.How far the photo can be zoomed past "just covers the frame".
Replaces the zoom-in button's icon.
Replaces the zoom-out button's icon.
Ref to the root element.
Events
Called with the crop whenever it changes, and with
nullwhile loading or on error.
Text
Every word the cropper shows or announces, from the app's translations. English by default. A
LabelsProvidersets them for the whole app.Names the area that holds the photo.
labels.instructionstypestringdefault"Drag, or use the arrow keys, to move the photo. Use plus and minus to zoom, and 0 to reset."How to move and zoom without a pointer; read by screen readers.
Names the zoom slider.
Names the zoom-in button.
Names the zoom-out button.
Shown when the photo can't be opened.
Classes on the outermost element; merged with
classNames.root.Classes for each part, merged over the library's.
The outermost element; merged with
className.The area that holds the photo and takes drags, pinches and keys.
The photo.
The frame: what is kept, with the dimmed photo around it.
The dashed circle in the frame (
guide="circle").The skeleton shown in the frame while the photo loads.
The message shown when the photo can't be opened.
The row with the zoom buttons and slider.
The zoom slider.
The zoom-out button.
The zoom-in button.
Inline styles for the root element.
Also accepts the root element's HTML attributes (id, data-*, event handlers).
Spec status
Not part of Material Design 3: a Windmorph Pro component, built on M3's colour roles, type scale, shapes and motion. Its variants and configurations each link to a live example.
| Item | Status | Details |
|---|---|---|
In a dialog (ImageCropDialog) | Built | Variant · Avatar |
Inline (ImageCropper) | Built | Variant · Inline |
| Round avatar guide | Built | Configuration · Avatar |
| Frame aspect ratio | Built | Configuration · Inline |
Saving with progress (pending, progress) | Built | Configuration · Avatar |
| Built on the M3 dialog | Extension | Full screen with the M3 full-screen dialog’s header on compact windows, and a basic dialog on larger ones. |
In a dialog (
BuiltImageCropDialog)Variant · Avatar
Inline (
BuiltImageCropper)Variant · Inline
Round avatar guide
BuiltConfiguration · Avatar
Frame aspect ratio
BuiltConfiguration · Inline
Saving with progress (
Builtpending,progress)Configuration · Avatar
Built on the M3 dialog
ExtensionFull screen with the M3 full-screen dialog’s header on compact windows, and a basic dialog on larger ones.
M3 Expressive specs
- Shape
rounded-corner-medium
Theming
- The area is
surface-container-highestwith medium corners; outside the frame the photo is dimmed withscrimat M3's 32%, as a dialog's scrim. In forced colours the dimmed photo around the frame stays visible. - The frame is a 2px
outline-variantedge, andguide="circle"adds a dashed circle showing what a round avatar shows. Forced colours draw both in the system text colour. classNamesstyles the cropper'sroot,area,image,frame,guide,skeleton,error,controls,slider,zoomOutandzoomIn. OnImageCropDialogit also takes the dialog'sscrim,panel(its surface) andcontent, andclassNamegoes on the outermost full-window layer, as on the coreDialog.ImageCropDialog'sref,id,aria-*anddata-*attributes go on the dialog panel (the element withrole="dialog"), as on the coreDialog.zoomInIconandzoomOutIconreplace the zoom buttons' icons, on both components.- The dialog's panel carries the core Dialog's token set (
data-tokens="md-comp-dialog wm-image-crop-dialog"), so a--md-comp-dialog-*theme reaches it; the cropper is markeddata-tokens="wm-image-cropper". - Resetting with 0 eases the photo back on the M3 effects spring, which never uncovers the frame; under reduced motion it jumps there.