
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
react-mask-editor
Advanced tools
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.
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.
First, some setup:
yarn install react-mask-editor
import { MaskEditor, toMask } from "react-mask-editor";
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:
Prop | Description | Default |
---|---|---|
cursorSize | Radius (in pixels) of the brush for editing the mask | 10 |
onCursorSizeChange | Callback fired when the user changes the brush size via mousewheel. If not provided, mouse wheel events will be ignored. | undefined |
maskOpacity | CSS opacity, decimal between 0 – 1 | 0.75 |
maskColor | A hex color (with or without leading '#'). | #23272d |
maskBlendMode | The CSS blending mode for the mask layer. Doesn't affect the output mask, just how it renders on top of your source image. | normal |
FAQs
General-purpose mask editor for React image manipulation apps
The npm package react-mask-editor receives a total of 99 weekly downloads. As such, react-mask-editor popularity was classified as not popular.
We found that react-mask-editor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.