Image cropper
Picking the part of an image to keep, by pointer, touch, wheel and keyboard, with a set shape, a circle or a free one. Saving cuts the crop out of the file.
Examples
Default
The image pans and zooms under a still frame. Pick a shape, and save the crop from onValueCommitted.
Box
With mode="box" the image stays still and a selection moves over it: drag its edges to resize it, or drag outside it to draw a new one.
Settle
With mode="settle" you resize the selection over the image, and when you let go it glides back to fill the area while the image zooms to match.
Drag or use the arrow keys to move the image, pinch or press plus and minus to zoom, and press R to rotate, or Shift and R to rotate back.
- Position
- –
- Size
- –
- Rotation
- –
Controlled
Hold the crop with value and onValueChange. It is null until there is one: the cropper then starts from the largest crop it can and reports it.
Circle
With shape="circle" the crop is round, and cropImage saves it as a PNG with clear corners.
Installation
npx shadcn@latest add https://kinoui.com/r/image-cropper.json- Files
lib/refs.tslib/reduce-motion.tslib/resize.tslib/swap.tsxcomponents/kino/spinner.tsxcomponents/kino/button.tsxlib/track.tslib/number-format.tscomponents/kino/slider.tsxlib/announce.tsxlib/run-progress.tslib/highlight.tscomponents/kino/image-cropper.tsx- Packages
@base-ui/reactclass-variance-authority- Global CSS
- the feels, the density tokens, the shape tokens and the success and warning colours
New to Kino? Installation covers what your project needs first and the @kino namespace.
API reference
ImageCropper
ImageCropperArea
cropImage
Data attributes
Accessibility
- The area is one stop in the tab order. Arrow keys move the crop (with Shift, further), plus and minus zoom, R turns the image and Shift and R turns it back. In
boxandsettle, Alt and the arrows resize the selection. Escape cancels a drag. - The area is an application, so a screen reader in browse mode passes its keys on. Its instructions are its description.
- The crop is announced in words once a key is let go, and every zoom, turn and load error is announced in a status region.
- The zoom has a Slider and two buttons, and the turn a button, so nothing needs a pointer, a wheel or two fingers.
- The wheel zooms only once the area has focus, or with Ctrl or Cmd held, so it never takes over the page’s scrolling.
