Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-mask-editor

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-mask-editor

General-purpose mask editor for React image manipulation apps

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
30
decreased by-34.78%
Maintainers
1
Weekly downloads
 
Created
Source

React Mask Editor

A drop-in component to add simple image mask editing to your React application. Uses <canvas> for rendering & interaction, with optional support for customizing how the mask is displayed & edited.

Online demo & documentation

Wait, what do you mean by "mask editor"?

You give React Mask Editor an image, and it lets the user 'scribble' over that image to create a 1-bit (black or white) mask. Think Photoshop, Lightroom, or Aperture.

Quick Start

First, some setup:

  • Add to your dependencies with yarn install react-mask-editor
  • Import with import { MaskEditor, toMask } from "react-mask-editor";
  • Include node_modules/react-mask-editor/dist/style.css somewhere in your bundle.

Usage:

  const MyComponent: React.FC<{}> = () => {
    const canvas = React.useRef<HTMLCanvasElement>();

    return <>
      <MaskEditor
        src="https://placekitten/256/256"
        canvasRef={canvas}
      />
      <button
        onClick={() => console.log(toMask(canvas.current))}
      >
        Get Mask
      </button>
    </>
  }

You can customize the editor using additional, optional props:

PropDescriptionDefault
cursorSizeRadius (in pixels) of the brush for editing the mask10
onCursorSizeChangeCallback fired when the user changes the brush size via mousewheel. If not provided, mouse wheel events will be ignored.undefined
maskOpacityCSS opacity, decimal between 0 – 10.75
maskColorA hex color (with or without leading '#').#23272d
maskBlendModeThe CSS blending mode for the mask layer. Doesn't affect the output mask, just how it renders on top of your source image.normal

Keywords

FAQs

Package last updated on 05 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc