1.0.6 â€ĸ Published 9 months ago

scratchy-card v1.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

Scratchy Component

The Scratchy Card component is an interactive scratch card based on React that allows users to reveal hidden content in a fun and engaging way by scratching off a layer. Its highly customizable design perfectly adapts to any project, providing easy integration options that enhance the interactivity and engagement of your application.

Try the DEMO

Contents

  1. 📌 Features
  2. đŸŽ¯ Installation
  3. đŸ•šī¸ Usage
  4. đŸ§Ŧ Props

📌 Features

  • Interactive Scratching: Users can scratch to reveal hidden content.
  • Customizable Appearance: Change the foreground and background colors, brush size, and border radius.
  • Responsive Design: Automatically adjusts to the size of the container.
  • Transition Effects: Smooth fading when the reveal is complete.

đŸŽ¯ Installation

npm i scratchy-card

đŸ•šī¸ Usage

To use the Scratchy component, import it and provide the required props:

import Scratchy from "./Scratchy";

const App = () => {
  return (
    <Scratchy
      imageSrc="path/to/your/image.jpg"
      foregroundColor="#C0C0C0"
      backgroundColor="#FFFFFF"
      brushSize={30}
      revealPercent={50}
      borderRadius={10}
      transitionDuration="1s"
    >
      <div>Your hidden content goes here!</div>
    </Scratchy>
  );
};

export default App;

đŸ§Ŧ Props

PropTypeDefault ValueDescription
imageSrcstring-Image URL for the scratchable layer.
foregroundColorstring#C0C0C0Color of the scratchable overlay (if no image).
backgroundColorstring#FFFFFFThe background color behind the scratchable layer.
brushSizenumber30The size of the brush used for scratching.
widthstring100%The width of the card.
heightstring100%The height of the card.
revealPercentnumber50The percentage of the area that must be scratched to uncover content.
transitionDurationstring1sThe duration of the reveal transition.
borderRadiusnumber0The border radius for the component.

Contributing

Contributions are welcome! If you have suggestions for improvements or new features, please open an issue or submit a pull request.

License

This project is licensed under the MIT License.

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago