Git Product home page Git Product logo

reactive-button's Introduction

Reactive Button

Reactive Button

3D animated react button component with progress bar.


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

Install via Yarn

yarn add reactive-button

Usage

For complete usage, visit the docs.

The below example demonstrates an asynchronous task. When clicking the button, an asynchronous task (e.g. Data fetch, form submit) will be processed and after processing, a success or error message will be displayed.

  • Initialize a state with string value 'idle' and assign it as 'buttonState' prop. Now it will render an idle text.
  • When the button is clicked, set 'buttonState''s value to 'loading'.
  • When the task is completed, set 'buttonState' to 'success', 'error' or 'idle' according to your need.

Basic Usage

import { useState } from 'react';
import ReactiveButton from 'reactive-button';

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

  const onClickHandler = () => {
    setState('loading');
    setTimeout(() => {
      setState('success');
    }, 2000);
  };

  return <ReactiveButton buttonState={state} onClick={onClickHandler} />;
}

export default App;

Full Usage

import { useState } from 'react';
import ReactiveButton from 'reactive-button';

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

  const onClickHandler = () => {
    setState('loading');
    setTimeout(() => {
      setState('success');
    }, 2000);
  };

  return (
    <ReactiveButton
      buttonState={state}
      onClick={onClickHandler}
      color={'primary'}
      idleText={'Button'}
      loadingText={'Loading'}
      successText={'Success'}
      errorText={'Error'}
      type={'button'}
      className={'class1 class2'}
      style={{ borderRadius: '5px' }}
      outline={false}
      shadow={false}
      rounded={false}
      size={'normal'}
      block={false}
      messageDuration={2000}
      disabled={false}
      buttonRef={null}
      width={null}
      height={null}
      animation={true}
    />
  );
}

export default App;

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

Contribute

To contribute, see the Contributing guide.

Support

Buy Me A Coffee

License

Reactive Button is licensed under the MIT License.

reactive-button's People

Contributors

arifszn avatar strawhat-dev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.