npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, πŸ‘‹, I’m Ryan HefnerΒ  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you πŸ™

Β© 2024 – Pkg Stats / Ryan Hefner

@neoconfetti/react

v0.1.1

Published

Confetti explosion in React πŸŽ‰πŸŽŠ

Downloads

1,510

Readme

@neoconfetti/react

Let's party 🎊🎊 with React! @neoconfetti/svelte allows you to show an awesome confetti explosion on your page, with React/Preact/Million!

Features

  • 🀏 Tiny - 1.61KB min+br.
  • πŸ‡ Simple - Quite simple to use, and effectively no-config required!
  • πŸ—ƒοΈ Customizable - Offers tons of options that you can modify to get different behaviors.
  • πŸ–₯️ SSR friendly - Works seamlessly in NextJS/Remix/Gatsby/Redwood and other Server Side Rendering environments!

Installing

# pnpm
pnpm add @neoconfetti/react

# bun
bun install @neoconfetti/react

# npm
npm install @neoconfetti/react

Usage

Basic usage:

import { Confetti } from '@neoconfetti/react';

<Confetti />;

Customizing behavior with options:

<Confetti particleCount={200} force={0.3} />

Props

There's tons of options available for this package. All of them are already documented within the code itself, so you'll never have to leave the code editor.

particleCount

Number of confetti particles to create.

type: number

Default value: 150

Example:

<Confetti particleCount={200} />

particleSize

Size of the confetti particles in pixels

type: number

Default value: 12

Example:

<Confetti particleSize={20} />

particleShape

Shape of particles to use. Can be mix, circles or rectangles

mix will use both circles and rectangles circles will use only circles rectangles will use only rectangles

type: 'mix' | 'circles' | 'rectangles'

Default value: 'mix'

Example:

<Confetti particleShape="circles" />

duration

Duration of the animation in milliseconds

type: number

Default value: 3500

Example:

<Confetti duration={5000} />

colors

Colors to use for the confetti particles. Pass string array of colors. Can use hex colors, named colors, CSS Variables, literally anything valid in plain CSS.

type: Array<string>

Default value: ['#FFC700', '#FF0000', '#2E3191', '#41BBC7']

Example:

<Confetti colors={['#FFC700', '#FF0000', '#2E3191', '#41BBC7']} />

force

Force of the confetti particles. Between 0 and 1. 0 is no force, 1 is maximum force. Will error out if you pass a value outside of this range.

type: number

Default value: 0.5

Example:

<Confetti force={0.3} />

stageHeight

Height of the stage in pixels. Confetti will only fall within this height.

type: number

Default value: 800

Example:

<Confetti stageHeight={500} />

stageWidth

Width of the stage in pixels. Confetti will only fall within this width.

type: number

Default value: 1600

Example:

<Confetti stageWidth={1000} />

destroyAfterDone

Whether or not destroy all confetti nodes after the duration period has passed. By default it destroys all nodes, to free up memory.

type: boolean

Default value: true

Example:

<Confetti destroyAfterDone={false} />

Fine-grained reactivity

Changing the options will destroy the existing confetti mid-flight, and create a new one with the new options. Exception: If particlesCount isn't changed, and properties like colors or particleShape is changed, the confetti particles will change their colors or shape mid-flight.

Performance

This library functions by creating 2 DOM nodes for every single confetti. By default, if the particlesCount is set to 150, it will create 300 nodes. This is a lot of nodes. For most devices, these many nodes are not a big issue, but I recommend checking your target devices' performance if you choose to go with a higher number, like 400 or 500.

Also, after the specified duration, all the confetti DOM nodes will be destroyed. This is to free up memory. If you wish to keep them around, set destroyAfterDone to false.

Credits

This library is the port of the amazing react-confetti-explosion package, just 10X smaller and faster. All the logic is from that package only, optimisation and Svelte code are mine πŸ˜‰

License

MIT License Β© Puru Vijay