# next-scratchcard

> The `ScratchCard` component for React provides an interactive scratch-off effect that reveals content underneath a scratchable surface. It's ideal for creating engaging experiences like scratch-off cards for promotions, games, or revealing hidden messages

Latest version **0.0.4** (published 2023-12-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install next-scratchcard
pnpm add next-scratchcard
yarn add next-scratchcard
bun add next-scratchcard
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2023-12-16 |
| First published | 2023-12-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 2 |
| Unpacked size | 52.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ankit Tailor |
| Maintainers | madhavb230100, ankit-tailor |
| Keywords | react-scratchcard, scratch-off-effect, interactive-canvas, react-ui-component, scratch-reveal |

## Links

- npm: https://www.npmjs.com/package/next-scratchcard
- npm.io page: https://npm.io/package/next-scratchcard

## Dependencies (2)

- [postcss](https://npm.io/package/postcss.md) ^8.4.29
- [rollup-plugin-postcss](https://npm.io/package/rollup-plugin-postcss.md) ^4.0.2

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 0.0.4 (latest) — 2023-12-16
- 0.0.3 — 2023-12-16
- 0.0.2 — 2023-12-16
- 0.0.1 — 2023-12-16

## README

# ScratchCard Component

The `ScratchCard` component for React provides an interactive scratch-off effect that reveals content underneath a scratchable surface. It's ideal for creating engaging experiences like scratch-off cards for promotions, games, or revealing hidden messages.

## Features

- **Customizable Dimensions**: Set the width and height of the scratch card.
- **Background Image Support**: Optionally include a background image that appears as the scratchable surface.
- **Dynamic Children Rendering**: Render custom React components or HTML elements beneath the scratchable surface.
- **Custom Brush Size**: Adjust the size of the scratching brush.
- **Completion Callback**: A callback function that triggers when a certain percentage of the surface has been scratched off.
- **Cross-Origin Image Support**: Handles CORS policy for images.

## Installation

```bash
npm i next-scratchcard
```

or

```bash
yarn add next-scratchcard
```

## Usage

Here's a basic example of how to use the `ScratchCard` component:

```jsx
import { ScratchCard } from 'next-scratchcard';

function App() {
  const handleComplete = () => {
    console.log('Scratch card completed!');
  };

  return (
    <ScratchCard finishPercent={30} brushSize={20} onComplete={handleComplete}>
      <img
        height={150}
        width={300}
        src="https://images.pexels.com/photos/14686115/pexels-photo-14686115.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2"
      />
    </ScratchCard>
  );
}
```

---
_Source: https://npm.io/package/next-scratchcard · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
