npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

cropperjs-react-wrapper

v1.0.0

Published

A React wrapper for Cropper.js 2.0

Readme

Cropper.js React

A modern, lightweight React wrapper for Cropper.js v2.

Features

  • ⚛️ React 18+ Support: Built for modern React applications.
  • 📦 Cropper.js v2: Fully embraces the Web Components architecture of Cropper.js 2.0.
  • 🧩 Component-Based: Compose your cropper using individual components (CropperCanvas, CropperImage, CropperSelection, etc.) for maximum flexibility.
  • 🟦 TypeScript: Fully typed for excellent developer experience.
  • 🚀 ESM Only: Modern module format.

Installation

npm install cropperjs-react-wrapper cropperjs
# or
yarn add cropperjs-react-wrapper cropperjs
# or
pnpm add cropperjs-react-wrapper cropperjs
# or
bun add cropperjs-react-wrapper cropperjs

Usage

Basic Example

Compose the components to build your cropping interface. This gives you full control over the layout and behavior.

import React from 'react';
import {
  CropperCanvas,
  CropperImage,
  CropperSelection,
  CropperHandle,
  CropperGrid,
  CropperCrosshair,
} from 'cropperjs-react-wrapper';

const App = () => {
  return (
    <div style={{ width: '100%', height: 400 }}>
      <CropperCanvas background>
        <CropperImage
          src="https://fengyuanchen.github.io/cropperjs/images/picture.jpg"
          alt="Picture"
          rotatable
          scalable
          skewable
          translatable
        />
        <CropperSelection initialCoverage={0.5} movable resizable zoomable>
          <CropperGrid role="grid" covered bordered />
          <CropperCrosshair centered />
          <CropperHandle action="move" themeColor="rgba(255, 255, 255, 0.35)" />
          <CropperHandle action="n-resize" />
          <CropperHandle action="e-resize" />
          <CropperHandle action="s-resize" />
          <CropperHandle action="w-resize" />
          <CropperHandle action="ne-resize" />
          <CropperHandle action="nw-resize" />
          <CropperHandle action="se-resize" />
          <CropperHandle action="sw-resize" />
        </CropperSelection>
      </CropperCanvas>
    </div>
  );
};

export default App;

Components

The library exports React components that wrap the corresponding Cropper.js 2.0 custom elements:

| Component | Cropper.js Element | Description | | --- | --- | --- | | CropperCanvas | <cropper-canvas> | The main container for the cropper. | | CropperImage | <cropper-image> | The image to be cropped. Supports transformations. | | CropperSelection | <cropper-selection> | The crop box selection area. | | CropperGrid | <cropper-grid> | A grid displayed within the selection. | | CropperCrosshair | <cropper-crosshair> | A crosshair displayed within the selection. | | CropperHandle | <cropper-handle> | Interactive handles for resizing or moving the selection. | | CropperShade | <cropper-shade> | An overlay shade for the non-selected area. |

Accessing Methods

You can access the underlying DOM elements and their methods (like $rotate, $scale, $toCanvas) using React refs.

import { useRef } from 'react';
import { CropperImage, type CropperImageElement } from 'cropperjs-react-wrapper';

const App = () => {
  const imageRef = useRef<CropperImageElement>(null);

  const handleRotate = () => {
    imageRef.current?.$rotate('90deg');
  };

  return (
    <>
      <button onClick={handleRotate}>Rotate</button>
      <CropperCanvas>
        <CropperImage ref={imageRef} src="..." />
        {/* ... */}
      </CropperCanvas>
    </>
  );
};

Development

Commands

  • npm run dev: Start the development server (includes a demo app).
  • npm run build: Build the library.
  • npm run test: Run tests using Vitest.
  • npm run lint: Run linting using Biome.

License

MIT