Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Circular Crop Gallery Block for React

A circle cropper with four drawn pictures to pick from and the crop live at three profile-picture sizes, with zoom buttons and a reset.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A circular-crop gallery for React with Base UI, for Roundwick, a profile-picture maker. A compact header has a "Picture" toggle at its end with four drawn pictures, each with its subject to one side so the crop matters. Under it a split: a framed image cropper with a circle selection that you drag, resize from its handles, nudge with the arrow keys and zoom with the wheel, with plus and minus, or with the Zoom buttons; and, beyond a divider, the crop live at three sizes (96, 48 and 24 pixels, as a profile page, a comment and a mention show it) with its size in pixels. Reset puts the circle back and clears the zoom. The pictures are drawn greys served to the cropper as SVG data URIs, not photographs: an image cannot read your theme's custom properties, so those few greys are fixed numbers. Nothing is uploaded; the crop only feeds the three previews. It's built from Image Cropper, Toggle Group, Button and Guides. The company is made up for the example.

FAQ

How do I use my own pictures?

Each entry in PICTURES has an id, a label, a description and a src. Replace src with your image's address (or a data URI), keep the description as its alt text, and the cropper and the three previews both use it. Keep the picture square, or change the cropper's aspect-square and the readout, which assumes a square one.

How do I crop with a keyboard?

Tab to the circle, then the arrow keys nudge it (hold Shift for bigger steps) and plus and minus zoom the picture. The Zoom out and Zoom in buttons do the same by pressing, and Reset puts everything back. The cropper's selection announces its position and how to use it for a screen reader.

How do the previews follow the crop?

The cropper sets inline styles on the picture and on the circle as you move them. The block watches those styles, measures the circle against the picture on the next frame and turns the result into three numbers: where the crop starts and how wide it is, as shares of the picture. Each preview is the same picture, scaled and shifted so that crop fills its circle. Nothing is read back from a canvas, so it works with any picture.

How do I get the cropped file?

This demo only previews. To produce a file, read the crop from the cropper's own API (its getCroppedImage returns a blob or a data URL) in your own handler, and upload that.

Why are the pictures SVG data URIs?

The cropper takes an image address, and a data URI keeps the block self-contained: no files to host and no network request. Its fills are fixed greys rather than theme tokens, because an image loaded this way cannot see the page's custom properties.

How does it fit on a phone?

The cropper sits above the previews, which become a row of three circles with their sizes under them. Dragging works with a finger and pinching zooms; the Zoom buttons are there when pinching is awkward.

  • Pro

    Zoom and Pan Viewer Gallery

    Compare, crop and zoom

    A framed viewport onto one large drawn city plan that you zoom and pan by buttons, a slider, keys, drag, double-click, Control or Command with the wheel, and a two-finger pinch.

  • Pro

    Six drawn pictures in cells of their own, with a Ratio control (1:1, 4:3, 16:9, 3:2, 9:16, 21:9) that crops every picture to it while keeping each subject in frame, and a chip on every picture naming the ratio.

  • Pro

    Image Comparison Slider Gallery

    Compare, crop and zoom

    A graded drawn picture revealed over its original by a handle you drag or a slider you step, with Original and Graded labels, a percent readout and a picker of three pictures.

  • Pro

    Hover Card Mosaic Team

    Grids and walls

    The planners of an interior-planning studio as a mosaic of mixed spans that shares its hairlines: a two-by-two lead cell, two wide cells, three small ones and a +12 cell, each person a link with a hover card that opens on hover and on focus.

  • Pro

    Hexagonal Honeycomb Gallery

    Masonry and mosaic

    Nineteen hexagonal pictures in an offset honeycomb inside a framed figure, moved across with the arrow keys, the current tile enlarged and named in a live caption.

  • Pro

    Twenty-four small drawn pictures on shared hairlines whose columns follow a Density slider, each offering one action, Copy link, that confirms in place.