• Stars
    star
    121
  • Rank 284,759 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 3 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

3D animated react button component with progress bar.

3D animated react button component with progress bar.

Documentation ยท Report Bug ยท Request Feature

Reactive Button Preview

Reactive Button is a 3D animated react component to replace the traditional boring buttons. Change your button style without adding any UI framework. Comes with progress bar and the goal is to let the users visualize what is happening after a button click.

  • 3D
  • Animated
  • Supports icons
  • Zero dependency
  • Progress indicator
  • Notification message
  • Supports TypeScript
  • Super easy to setup
  • Extremely lightweight
  • Super easy to customize
  • And much more !

Resources

Installation

Install via NPM.

npm install reactive-button

Or via Yarn.

yarn add reactive-button

Usage

The targets of the below example:

  • Show a button showing the text 'Submit'.
  • After clicking the button, change the button text to 'Loading' and send an HTTP request.
  • Upon successful request, change the button text to 'Done' as success notification.
import { useState } from 'react';
import ReactiveButton from 'reactive-button';

function App() {
  const [state, setState] = useState('idle');

  const onClickHandler = () => {
    setState('loading');

    // send an HTTP request
    setTimeout(() => {
      setState('success');
    }, 2000);
  };

  return (
    <ReactiveButton
      buttonState={state}
      idleText="Submit"
      loadingText="Loading"
      successText="Done"
      onClick={onClickHandler}
    />
  );
}

export default App;

Other Usage

Reactive Button has all the functionalities of a normal button.

Color

It comes with 10 default color options.

return (
  <>
    <ReactiveButton color="primary" />
    <ReactiveButton color="secondary" />
    <ReactiveButton color="teal" />
    <ReactiveButton color="green" />
    <ReactiveButton color="red" />
    <ReactiveButton color="violet" />
    <ReactiveButton color="blue" />
    <ReactiveButton color="yellow" />
    <ReactiveButton color="dark" />
    <ReactiveButton color="light" />
  </>
);

Size

There are 4 sizes available.

return (
  <>
    <ReactiveButton size="tiny" />
    <ReactiveButton size="small" />
    <ReactiveButton size="medium" />
    <ReactiveButton size="large" />
  </>
);

Style

Make the buttons more beautiful with these customization options.

return (
  <>
    <ReactiveButton outline />
    <ReactiveButton rounded />
    <ReactiveButton shadow />
  </>
);

Existing State

In your project, There might be existing state for loading indicator which accepts boolean value only. If you don't want to define new state for Reactive Button, then utilize the existing state.

const [loading, setLoading] = useState(false);

return (
  <ReactiveButton
    buttonState={loading ? 'loading' : 'idle'}
    idleText={'Button'}
    loadingText={'Loading'}
  />
);

Without State

state is not mandatory.

return <ReactiveButton onClick={onClickHandler} />;

Using Icons

You can use your own icons. Don't forget to wrap them with a parent element.

return (
  <ReactiveButton
    idleText={
      <span>
        <faReply /> Send
      </span>
    }
  />
);

Form Submit

If you need to submit form by button clicking, set the type prop as 'submit'.

return (
  <form>
    <input type="text" name="username" />
    <input type="password" name="password" />
    <ReactiveButton type={'submit'} idleText="Submit" />
  </form>
);

Anchor Tag

To use Reactive button as anchor tag, simply wrap it with an anchor tag.

return (
  <a href="https://github.com/" target="_blank">
    <ReactiveButton idleText="Visit Github" />
  </a>
);

Available Props

Props Type Description Default
buttonState string 'idle' | 'loading' | 'success' | 'error' 'idle'
onClick function Callback function when clicking button () => {}
color string 'primary' | 'secondary' | 'dark' | 'light' | 'green' | 'red' | 'yellow' | 'teal' | 'violet' | 'blue' 'primary'
idleText string | ReactNode Button text when idle 'Click Me'
loadingText string | ReactNode Button text when loading 'Loading'
successText string | ReactNode Button text when loading successful 'Success'
errorText string | ReactNode Button text when loading failed 'Error'
type string 'button' | 'submit' | 'reset' 'button'
className string Button classnames ''
style React.CSSProperties Custom style {}
outline boolean Enable outline effect false
shadow boolean Enable shadow effect false
rounded boolean Enable rounded button false
size string 'tiny' | 'small' | 'normal' | 'large' 'normal'
block boolean Block Button false
messageDuration number Success/Error message duration in millisecond 2000
disabled boolean Disable button false
buttonRef React.Ref | null Button reference null
width string | null Override button width null
height string | null Override button height null
animation boolean Button hover and click animation true

Support

You can show your support by starring this project.

Github Star

Contribute

To contribute, see the contributing guide.

License

MIT License

More Repositories

1

gitprofile

๐Ÿš€ Create a dynamic portfolio by just providing your GitHub username.
JavaScript
1,170
star
2

ezfolio

Open Source Portfolio/Resume CMS built using Laravel, React and Ant Design.
PHP
237
star
3

OneClick

Navigate to your favorite actions on the websites you love with just one click.
JavaScript
72
star
4

react-laravel

A simple crud based laravel app to learn how to use react with laravel.
PHP
60
star
5

reddit-image-fetcher

A JavaScript package for fetching reddit images, memes, wallpapers and more.
JavaScript
42
star
6

reforge

๐ŸŽฒ An out-of-box UI solution for enterprise applications as a React boilerplate.
TypeScript
39
star
7

blog.js

JavaScript client to get recent blog posts from popular blogging platforms.
JavaScript
37
star
8

pandora

๐ŸฅขREST API starter kit powered by Laravel, OpenAPI, Sanctum.
CSS
33
star
9

find-me

Server less face recognition app built with face-api.js and React
JavaScript
16
star
10

react-offline-indicator

โšก Offline detector and indicator for your React app.
JavaScript
14
star
11

laravel-advanced-validation

Laravel advanced validation rules for real-life scenarios.
PHP
13
star
12

php-blog-client

PHP client to get recent blog posts from popular blogging platforms.
PHP
11
star
13

email-scraper

An email scraper made with Node and React.
CSS
10
star
14

reddit-image-fetcher-php

A PHP package for fetching reddit images, memes, wallpapers and more.
PHP
9
star
15

memeDB

Auto fetched memes and wallpapers viewer made with React.
JavaScript
9
star
16

vail

โ›ต๏ธDocker powered local development experience for JavaScript/TypeScript Apps. ๐Ÿณ
JavaScript
9
star
17

arifszn

Config files for my GitHub profile.
7
star
18

simple-crud-backend

An API based backend built with Laravel.
PHP
3
star
19

simple-crud

A crud based single page application made with react and ant design.
Less
3
star
20

meme.js

JavaScript package to get memes on browser/server.
JavaScript
3
star
21

chatpad

A simple chat application made with laravel and socket io.
PHP
2
star
22

read-it

Read word by word by setting words per minute.
HTML
2
star
23

read-it-later

A REST api based project like mozilla pocket
PHP
2
star
24

mern-mailer

Made with MongoDB, Express.js, React and Node.
JavaScript
2
star
25

wallpaper.js

JavaScript package to get wallpapers on browser/server.
JavaScript
2
star
26

firebase-sdk-frontend-demo

JavaScript
1
star
27

laravel-docker-boilerplate

Docker boilerplate to run Laravel project.
Dockerfile
1
star
28

.github

Default community health files.
1
star
29

laravel-ddd-template

Laravel Domain Driven Design Template
PHP
1
star