Componentpickers1.86 KB gzipZero dependencies

Image Crop

Canvas-based image cropping with draggable crop rect, rule-of-thirds grid, resize handles, and dataURL output.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add image-crop

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { ImageCrop } from "@/components/ui/image-crop"; <ImageCrop src="image.jpg" aspect={1.5} onCrop={setDataUrl} />

Source code

image-crop.tsx + 1 helper

Zero third-party dependencies (2 local files shown in tabs below).

tsximage-crop.tsx296 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; /** * ImageCrop - canvas-based image cropping with pointer events */interface ImageCropProps {  src: string;  aspect?: number;  onCrop?: (dataUrl: string) => void;} /** * Get natural image dimensions */const getImageNaturalSize = (src: string): Promise<{ width: number; height: number }> => {

Props

Interactive Prop Playground

Tweak parsed AST props below to generate ready-to-paste JSX.

tsx3 lines
import { ImageCrop } from "@/components/ui/image-crop"; <ImageCrop />
PropTypeDescription
srcstringImage source URL.
aspectnumberAspect ratio lock (e.g. 1.5 for 3:2).
onCrop(dataUrl: string) => voidCallback with cropped dataURL.