Confetti Component

This documentation provides information on how to use the confetti function to create a confetti animation on a webpage.

To unlock early access to the component Get Access

Installation

To install the Quest react-sdk into your project, follow these steps:

  • Open your terminal/command prompt.

  • Navigate to your project's root directory using the cd command if you're not already there.

  • Run the following command to install the quest-sdk package using npm:

npm install @questlabs/react-sdk

This command will download and install the package and its dependencies into your project.

Make sure your project has npm and Node.js installed, and that you have the necessary permissions to install packages in your project directory.

Usage

To use the confetti function, follow these steps:

  1. Import the confetti function if it's in a separate module:

    import { confetti } from '@questlabs/react-sdk'; // Import the confetti module.
    import '@questlabs/react-sdk/dist/style.css'
  2. Call the confetti function with an optional duration (in milliseconds):

    javascriptCopy code// Example: Display confetti for 3 seconds (3000 milliseconds).
    confetti(3000);
  3. The confetti animation will be displayed on the webpage for the specified duration, and then it will automatically disappear.

Example Usage

Here's an example of how to use the confetti function within your web application:

import { confetti } from '@questlabs/react-sdk';  // Import the confetti module.

function celebrateEvent() {
  // Display confetti for 5 seconds (5000 milliseconds).
  confetti(5000);
}

// Trigger the confetti animation on a celebration event, like a button click.
celebrateEvent();

This documentation provides an overview of the confetti function, usage instructions, and an example of how to trigger the confetti animation in your web application. You can adapt it to your specific needs and provide more details if necessary.

Demo

Last updated