Bursting particle effect buttons for React 🎉

Overview

react-particle-effect-button (demo)

Bursting particle effect buttons for React.

NPM Build Status JavaScript Style Guide

Demo

This library is a React port of an awesome Codrops Article by Luis Manuel (original source).

Install

npm install --save react-particle-effect-button

Usage

Check out the Demo to see it in action.

import React, { Component } from 'react'

import ParticleEffectButton from 'react-particle-effect-button'

class App extends Component {
  state = {
    hidden: false
  }

  render () {
    return (
      <ParticleEffectButton
        color='#121019'
        hidden={this.state.hidden}
      >
        BUTTON CONTENT GOES HERE
      </ParticleEffectButton>
    )
  }
}

Note that children can be anything from a simple <button> to a complex React subtree. The children should represent the button's contents.

You change the hidden boolean prop to kick-off an animation, typically as a result of a click on the button's contents. If hidden changes to true, the button will perform a disintegrating animation. If hidden changes to false, it will reverse and reintegrate the original content.

Props

Property Type Default Description
hidden boolean false Whether button should be hidden or visible. Changing this prop starts an animation.
color string '#000' Particle color. Should match the button content's background color
children React Node undefined The contents of the button.
duration number 1000 Animation duration in milliseconds.
easing string 'easeInOutCubic' Animation easing.
type string circle 'circle' or 'rectangle' or 'triangle'
style string fill 'fill' or 'stroke'
direction string 'left' 'left' or 'right' or 'top' or 'bottom'
canvasPadding number 150 Amount of extra padding to add to the canvas since the animation will overflow the content's bounds
size number func random(4)
speed number func random(4)
particlesAmountCoefficient number 3 Increases or decreases the relative number of particles
oscillationCoefficient number 20 Increases or decreases the relative curvature of particles
onBegin func noop Callback to be notified once an animation starts.
onComplete func noop Callback to be notified once an animation completes.

I tried to keep the properties exactly the same as in the original codrops version.

Related

This module was bootstrapped with create-react-library.

License

MIT © Travis Fischer

Support my OSS work by following me on twitter twitter

Comments
  • Issue getting package to work

    Issue getting package to work

    I've set up a new environment with create-react-app and added this as a dependency. Using the following code in my App.js doesn't seem to do anything other than add the text "BUTTON CONTENT GOES HERE"

    <ParticleEffectButton
             color='palegreen'
             hidden={this.state.hidden}
             style='fill'
             children={'hey'}
           >
             <button>HEY</button>
           </ParticleEffectButton>
    

    Am I missing something? I have it imported and React is up to date.

    opened by nicer00ster 1
  • Warning: componentWillReceiveProps has been renamed, and is not recommended for use.

    Warning: componentWillReceiveProps has been renamed, and is not recommended for use.

    Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details.
    
    * Move data fetching code or side effects to componentDidUpdate.
    * If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state
    * Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.
    
    Please update the following components: ParticleEffectButton
    

    I got this warning when using it

    opened by Bat-m 0
  • Consider using display:

    Consider using display:"none" rather than visibility:"hidden" on canvas

    As mentioned, I think you should consider using display:"none" rather than visibility:"hidden" on canvas. Using visibility could cause some responsive issue as the canva's width is 3 times larger than the button's width. In your example, open it on mobile mode, it will cause responsive issue. https://transitive-bullshit.github.io/react-particle-effect-button/

    opened by duongthienlee 0
  • cannot read property 'match' of undefined

    cannot read property 'match' of undefined

    I get this error when I install the package using npm install --save react-particle-effect-button

    npm ERR! Cannot read property 'match' of undefined

    Here is the complete debug log:

    0 info it worked if it ends with ok 1 verbose cli [ 1 verbose cli '/home/praveen/.nvm/versions/node/v12.5.0/bin/node', 1 verbose cli '/home/praveen/.nvm/versions/node/v12.5.0/bin/npm', 1 verbose cli 'install', 1 verbose cli '--save', 1 verbose cli 'react-particle-effect-button' 1 verbose cli ] 2 info using [email protected] 3 info using [email protected] 4 verbose npm-session 4149384ab7b567a8 5 silly install loadCurrentTree 6 silly install readLocalPackageData 7 http fetch GET 304 https://registry.npmjs.org/react-particle-effect-button 1203ms (from cache) 8 silly pacote tag manifest for react-particle-effect-button@latest fetched in 1442ms 9 timing stage:loadCurrentTree Completed in 14120ms 10 silly install loadIdealTree 11 silly install cloneCurrentTreeToIdealTree 12 timing stage:loadIdealTree:cloneCurrentTree Completed in 14ms 13 silly install loadShrinkwrap 14 timing stage:rollbackFailedOptional Completed in 1ms 15 timing stage:runTopLevelLifecycles Completed in 14389ms 16 silly saveTree [email protected] 17 verbose stack TypeError: Cannot read property 'match' of undefined
    17 verbose stack at tarballToVersion (/home/praveen/.nvm/versions/node/v12.5.0/lib/node_modules/npm/lib/install/inflate-shrinkwrap.js:87:20) 17 verbose stack at inflatableChild (/home/praveen/.nvm/versions/node/v12.5.0/lib/node_modules/npm/lib/install/inflate-shrinkwrap.js:99:22) 17 verbose stack at /home/praveen/.nvm/versions/node/v12.5.0/lib/node_modules/npm/lib/install/inflate-shrinkwrap.js:55:12 17 verbose stack at tryCatcher (/home/praveen/.nvm/versions/node/v12.5.0/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23) 17 verbose stack at Object.gotValue (/home/praveen/.nvm/versions/node/v12.5.0/lib/node_modules/npm/node_modules/bluebird/js/release/reduce.js:155:18) 17 verbose stack at Object.gotAccum (/home/praveen/.nvm/versions/node/v12.5.0/lib/node_modules/npm/node_modules/bluebird/js/release/reduce.js:144:25) 17 verbose stack at Object.tryCatcher (/home/praveen/.nvm/versions/node/v12.5.0/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23) 17 verbose stack at Promise._settlePromiseFromHandler (/home/praveen/.nvm/versions/node/v12.5.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31) 17 verbose stack at Promise._settlePromise (/home/praveen/.nvm/versions/node/v12.5.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18) 17 verbose stack at Promise._settlePromiseCtx (/home/praveen/.nvm/versions/node/v12.5.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:606:10) 17 verbose stack at _drainQueueStep (/home/praveen/.nvm/versions/node/v12.5.0/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:142:12) 17 verbose stack at _drainQueue (/home/praveen/.nvm/versions/node/v12.5.0/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:131:9) 17 verbose stack at Async._drainQueues (/home/praveen/.nvm/versions/node/v12.5.0/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:147:5) 17 verbose stack at Immediate.Async.drainQueues [as _onImmediate] (/home/praveen/.nvm/versions/node/v12.5.0/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14) 17 verbose stack at processImmediate (internal/timers.js:439:21) 18 verbose cwd /home/praveen/tasks-and-projects/react-native/OrientationSite-frontend/orientation-web 19 verbose Linux 4.15.0-52-generic 20 verbose argv "/home/praveen/.nvm/versions/node/v12.5.0/bin/node" "/home/praveen/.nvm/versions/node/v12.5.0/bin/npm" "install" "--save" "react-particle-effect-button" 21 verbose node v12.5.0 22 verbose npm v6.9.0 23 error Cannot read property 'match' of undefined 24 verbose exit [ 1, true ]

    opened by gigatesseract 0
  • Button appears briefly after animation

    Button appears briefly after animation

    Is anyone else experiencing this where- after the button disintegrates- it flashes briefly just before the 'visibility: hidden' style is applied to the wrapper. Kinda ruins the effect...

    My code is as follows:

    class ItzAButton extends Component {
        constructor(props) {
            super(props)
    
            this.state = {
                hidden: false
            }
        }
    
        render() {
            return (
                <ParticleEffectButton
                    color='red'
                    hidden={this.state.hidden}
                    // duration={2000}
                    // type={['circle','rectangle','triangle'][Math.floor(Math.random()*3)]}
                >
                    <button
                        className="button button3"
                        onClick={() => this.setState({hidden: true})}
                    >Click Me!</button>
                </ParticleEffectButton>
            )
        }
    }
    

    Nothin' fancy.

    opened by mmarovich 1
Owner
Travis Fischer
Building a platform where OSS developers can get PAID for their expertise.
Travis Fischer
Buttons For The Web

cssbuttons.app Button collection with a focus on simplicity and ease of use. Tech Stack: Next.js, Tailwind CSS, CSS Report Bug Found a bug? Report it

Guilherme Rizzo 180 Dec 11, 2022
Recoil is an experimental state management library for React apps. It provides several capabilities that are difficult to achieve with React alone, while being compatible with the newest features of React.

Recoil · Recoil is an experimental set of utilities for state management with React. Please see the website: https://recoiljs.org Installation The Rec

Facebook Experimental 18.2k Jan 8, 2023
The Ripple Effect (An Ethereum-Based Fundraiser App)

The-Ripple-Effect---An-Ethereum-Based-Fundraiser-App - The Ripple Effect is a ethereum based fundraising app that can not only be used to donate to a specific cause but also to allocate/distribute funds with total transparency. The frontend has been made on ReactJS with the backend on Solidity with the help of Ganache.

Hassan Shahzad 4 Mar 14, 2022
An experimental hover effect, where a content preview is shown while a mini map indicates the position of the cursor.

Hover Preview Effect with Mini Map An experimental hover effect, where a content preview is shown while a mini map indicates the position of the curso

Codrops 27 Dec 29, 2022
React Starter Kit — isomorphic web app boilerplate (Node.js, Express, GraphQL, React.js, Babel, PostCSS, Webpack, Browsersync)

React Starter Kit — "isomorphic" web app boilerplate React Starter Kit is an opinionated boilerplate for web development built on top of Node.js, Expr

Kriasoft 21.7k Dec 30, 2022
📋 React Hooks for forms validation (Web + React Native)

English | 繁中 | 简中 | 日本語 | 한국어 | Français | Italiano | Português | Español | Русский | Deutsch | Türkçe Features Built with performance and DX in mind

React Hook Form 32.4k Dec 29, 2022
:black_medium_small_square:React Move | Beautiful, data-driven animations for React

React-Move Beautiful, data-driven animations for React. Just 3.5kb (gzipped)! Documentation and Examples Features Animate HTML, SVG & React-Native Fin

Steve Hall 6.5k Jan 1, 2023
React features to enhance using Rollbar.js in React Applications

Rollbar React SDK React features to enhance using Rollbar.js in React Applications. This SDK provides a wrapper around the base Rollbar.js SDK in orde

Rollbar 39 Jan 3, 2023
🎉 toastify-react-native allows you to add notifications to your react-native app (ios, android) with ease. No more nonsense!

toastify-react-native ?? toastify-react-native allows you to add notifications to your react-native app (ios, android) with ease. No more nonsense! De

Zahid Ali 29 Oct 11, 2022
Soft UI Dashboard React - Free Dashboard using React and Material UI

Soft UI Dashboard React Start your Development with an Innovative Admin Template for Material-UI and React. If you like the look & feel of the hottest

Creative Tim 182 Dec 28, 2022
A web application to search all the different countries in the world and get details about them which can include languages, currencies, population, domain e.t.c This application is built with CSS, React, Redux-Toolkit and React-Router.

A web application to search all the different countries in the world and get details about them which can include languages, currencies, population, domain e.t.c This application is built with CSS, React, Redux-Toolkit and React-Router. It also includes a theme switcher from light to dark mode.

Franklin Okolie 4 Jun 5, 2022
Finished code and notes from EFA bonus class on building a React project without create-react-app

React From Scratch Completed Code This is the completed code for the EFA bonus class on building a React project from scratch. Included are also markd

Conor Broaders 3 Oct 11, 2021
Free Open Source High Quality Dashboard based on Bootstrap 4 & React 16: http://dashboards.webkom.co/react/airframe

Airframe React High Quality Dashboard / Admin / Analytics template that works great on any smartphone, tablet or desktop. Available as Open Source as

Mustafa Nabavi 6 Jun 5, 2022
React tooltip is a React.JS Component that brings usefull UX and UI information in selected elements of your website.

React Tooltip ✅ React tooltip is a React.JS Component that brings usefull UX and UI information in elements of your website. Installation ⌨️ React Too

Marc Ramos 1 Dec 22, 2021
React-Mini-Projects - Simple React mini-applications

React Mini Projects A Fully Responsive React Application contain these mini apps : Todo App Movie App Budget App Flash Card App Factor App This app wa

Morteza Rezaienia 1 Jan 1, 2022
React-tutorial - A React tutorial from Udemy (Academind)

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Patrick James Nengasca 2 Mar 31, 2022
Airbnb-React - In this project, An Airbnb experience page clone is created to learn and implement React props concepts.

Create React Airbnb App In this project An airbnb experience page clone is created to learn and implement React props concepts. Objectives Learn about

Yogesh Gurjar 4 Jun 28, 2022
Vtexio-react-apps - Apps react para plafaforma VTEX.

Projeto Modal + Apps Extras Projeto modal setando cookies. Desenvolvido em React + TypeScript para aplicação em e-commerce VTEXIO. ?? Este projeto se

Marcelo 1 Jan 3, 2022
Chrome-extension-react-boilerplate - Simple Chrome extension React boilerplate.

Simple Chrome extension React boilerplate This is a simple chrome extension boilerplate made in React to use as a default structure for your future pr

Younes 6 May 25, 2022