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.
Keyboard
| Key | Action | Where |
|---|---|---|
| Tab | Moves between the dialog's buttons and, in the cropper, the photo area, Zoom out, the zoom slider and Zoom in. | |
| Arrow Up or Arrow Down or Arrow Left or Arrow Right | Move the photo 10px that way, or 50px with Shift. It stops where it would leave a gap in the frame.On the photo area | On the photo area |
| + or - | Zoom in by 10%, or back out by the same step (= and _ work too).On the photo area | On the photo area |
| 0 | Resets the photo to fill the frame, centred.On the photo area | On the photo area |
| Arrow Left or Arrow Right | Change the zoom, as on any Slider.On the zoom slider | On the zoom slider |
| Escape | Closes the dialog, except while pending.In the dialog | In the dialog |
The arrow keys move the photo the way they point in every layout direction.
Screen reader
- Role
- In the dialog, a
dialognamed by its title. Inside, the photo area is agroup, the zoom control aslider, and Zoom out and Zoom in are buttons. - Accessible name
- The photo area is named by
labels.area("Photo position") and described bylabels.instructions, which say how to move and zoom from the keyboard. The slider is named bylabels.zoomand the buttons bylabels.zoomOutandlabels.zoomIn. - States announced
- The slider reads its value as a percentage ("150%"). Zoom out and Zoom in are disabled at their limits, and Save until the photo is ready.
- The photo itself is decorative (
alt=""); the frame and the circle guide are hidden from assistive tech. - A photo that can't be opened (HEIC in some browsers, or a file that isn't an image) shows
labels.errorin analertregion that goes into the page before the message, so it is announced, and Save stays disabled. - The zoom buttons show their names as tooltips through the icon button, without reading them twice.
- While
pending, a progress bar named bylabels.pendingshows, Save is pending (it keeps focus and its name addslabels.pending: "Save, Uploading"), Cancel is disabled, and the dialog can't be dismissed.
Focus
- The photo area joins the Tab order once the photo has loaded, and shows M3's focus indicator on keyboard focus: a 3px
secondaryoutline 2px outside it. - When Zoom out or Zoom in reaches its limit and turns itself off, focus moves to the other zoom button (or the photo area) instead of dropping to the page.
- Pressing Save keeps focus on it while the app saves.
- The dialog moves focus to its first interactive element when it opens, keeps focus inside, and returns it to what opened it when it closes, as any
Dialogdoes.
Touch target
- The photo area spans the cropper's full width, with 24px around the frame.
- Zoom out and Zoom in are small icon buttons (40px) with an invisible 48 × 48px touch target.
- Dragging is never required: the zoom slider and buttons zoom, and the arrow keys move the photo (WCAG 2.2, 2.5.7). A pointer drags the photo, two fingers pinch to zoom, and Ctrl or ⌘ with the wheel (or a trackpad pinch) zooms around the pointer; a plain wheel scrolls the page.
- Inline, a vertical swipe over the photo scrolls the page while the photo has nothing to move vertically (a landscape photo at zoom 1), so the cropper never traps a touch screen. A portrait photo, or one zoomed in, takes the swipe to move. Inside the dialog every gesture moves the photo.
Motion
- Resetting with 0 eases the photo back on the M3 effects spring, which never uncovers the frame; under reduced motion it jumps there. Dragging, pinching and the wheel follow the pointer without easing.
- The dialog opens and closes with the
Dialogmotion.
What you need to do
- Pass
labelsfrom your translations, includinginstructions, the only place the keyboard controls are explained. - Keep the dialog open while you upload (
pending, withprogresswhen you know it), and close it yourself when the upload ends. - Offer a file type the browser can show (JPEG or PNG): pick files with
accepton aFileTrigger, and expect the error for others. - In forced-colours mode the frame edge and the circle guide use the system text colour and the photo around the frame stays dimmed but visible; keep
classNamesoverrides from removing them. - Give a custom
zoomInIconorzoomOutIconno name of its own: the button is named bylabels.