Skip to content

    Browse components

    Snap Crop

    Crop frame with springy corner handles that magnetically snap to edges, thirds and center, with snap guides and a live pixel-size readout.

    Open
    Customize

    Installation

    npx shadcn@latest add @glint-ui/snap-crop

    First time using @glint-ui? Add the registry to components.json once, or install by URL: npx shadcn@latest add https://glintui.vercel.app/r/snap-crop.json

    Usage

    import { SnapCrop } from "@/components/ui/snap-crop";
    
    <SnapCrop src={url} naturalWidth={1600} naturalHeight={1000} onChange={setCrop} />

    Props

    PropTypeDefaultDescription
    naturalWidthnumber1600Real image width in px (readout units).
    naturalHeightnumber1000Real image height in px.
    snapbooleantrueSnap edges to image edges, thirds and center.
    snapDistancenumber10Snap distance in screen px.
    minSizenumber0.15Smallest crop as a fraction of the image side.
    accentstring"#a3e635"Snap guide color.
    srcReactNode—Image URL.
    onChangeReactNode—(crop: { x, y, width, height }) => void, in image pixels.
    classNamestring—Extra classes for the root element.