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
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add image-cropOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { ImageCrop } from "@/components/ui/image-crop"; <ImageCrop src="image.jpg" aspect={1.5} onCrop={setDataUrl} />Source code
image-crop.tsx + 1 helperZero 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 />| Prop | Type | Description |
|---|---|---|
| src | string | Image source URL. |
| aspect | number | Aspect ratio lock (e.g. 1.5 for 3:2). |
| onCrop | (dataUrl: string) => void | Callback with cropped dataURL. |