HextaUI

Image cropper (UI SDK): Rotate and flip

ImageCropperRotate turns the image a quarter clockwise and ImageCropperFlip mirrors it. Without children they’re icon buttons with English labels.

A rowing boat on a green mountain lake
import {
  ImageCropper,
  ImageCropperFlip,
  ImageCropperGrid,
  ImageCropperHandles,
  ImageCropperImage,
  ImageCropperRotate,
  ImageCropperSelection,
  ImageCropperViewport,
} from "@/components/ui/ui-sdk-image-cropper"

const photo =
  "https://images.unsplash.com/photo-1501785888041-af3ef285b470?w=1200&q=80&auto=format&fit=crop"

function UiSdkImageCropperRotateFlip() {
  return (
    <ImageCropper
      aria-label="Photo"
      src={photo}
      aspectRatio={4 / 5}
      className="max-w-sm"
    >
      <ImageCropperViewport>
        <ImageCropperImage alt="A rowing boat on a green mountain lake" />
        <ImageCropperSelection>
          <ImageCropperGrid />
          <ImageCropperHandles />
        </ImageCropperSelection>
      </ImageCropperViewport>
      <div className="flex gap-2">
        <ImageCropperRotate />
        <ImageCropperFlip />
        <ImageCropperFlip direction="vertical" />
      </div>
    </ImageCropper>
  )
}

export { UiSdkImageCropperRotateFlip }

This adds the example as components/examples/ui-sdk-image-cropper/rotate-flip.tsx, together with the Image cropper component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/ui-sdk-image-cropper-rotate-flip.json

To add only the component, follow the Image cropper installation.

Props in this example

The Image cropper props this example sets, from the API reference.

PropTypeDefault
src
string–
aspectRatio
number–
PropTypeDefault
altRequired.
string–
PropTypeDefault
direction
"horizontal" | "vertical""horizontal"

Every prop is in the Image cropper API reference.

See them all, with keyboard support and accessibility notes, on the Image cropper page.