Skip to Content
Kokonut UI

MD-04Media

Photo Straighten

Level a crooked photo on a ruler you drag or flick. The crop grows to hide the corners, and a grid shows while you adjust.

Install with
lucide-react, motion

PROAudio Player Card and more like it are in Kokonut UI Pro

Installation

Photo Straighten is a free, open-source React component in the Kokonut UI Media collection. Add it with the shadcn CLI, which copies the source into components/kokonutui/photo-straighten.tsx, so the code is yours to change.

npx shadcn@latest add @kokonutui/photo-straighten

Or add it by hand: install its packages, then copy the source from Copy code above into components/kokonutui/photo-straighten.tsx.

npm install lucide-react motion

Usage

import PhotoStraighten from "@/components/kokonutui/photo-straighten";

export default function Example() {
  return <PhotoStraighten />;
}

Props

src
stringDefault built-in
alt
stringDefault "A lake below mountains"
aspectRatio
numberDefault 4 / 3

Width over height of the crop.

tilt
numberDefault 4.2

How crooked the photo is, in degrees; what Auto corrects. The demo tilts its photo by this much so there is something to fix.

defaultAngle
numberDefault 0
onAngleChange
(degrees: number) => void
className
string

Extra classes for the root element.

Dependencies

NeedsVersionComes from
lucide-react^0.556.0npm, installed by the CLI
motion^12.23.25npm, installed by the CLI
cn from lib/utils.tsshadcn init
React19Your app
Tailwind CSS4Your app

No provider, font or global CSS to set up: the file works as soon as it lands.