Skip to content

Repository files navigation


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';importReactiveButtonfrom'reactive-button';functionApp(){const[state,setState]=useState('idle');constonClickHandler=()=>{setState('loading');// send an HTTP requestsetTimeout(()=>{setState('success');},2000);};return(<ReactiveButtonbuttonState={state}idleText="Submit"loadingText="Loading"successText="Done"onClick={onClickHandler}/>);}exportdefaultApp;

Other Usage

Reactive Button has all the functionalities of a normal button.

Color

It comes with 10 default color options.

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

Size

There are 4 sizes available.

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

Style

Make the buttons more beautiful with these customization options.

return(<><ReactiveButtonoutline/><ReactiveButtonrounded/><ReactiveButtonshadow/></>);

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(<ReactiveButtonbuttonState={loading ? 'loading' : 'idle'}idleText={'Button'}loadingText={'Loading'}/>);

Without State

state is not mandatory.

return<ReactiveButtononClick={onClickHandler}/>;

Using Icons

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

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

Form Submit

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

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

Anchor Tag

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

return(<ahref="https://github.com/"target="_blank"><ReactiveButtonidleText="Visit Github"/></a>);

Available Props

PropsTypeDescriptionDefault
buttonStatestring'idle' | 'loading' | 'success' | 'error''idle'
onClickfunctionCallback function when clicking button() => {}
colorstring'primary' | 'secondary' | 'dark' | 'light' | 'green' | 'red' | 'yellow' | 'teal' | 'violet' | 'blue''primary'
idleTextstring | ReactNodeButton text when idle'Click Me'
loadingTextstring | ReactNodeButton text when loading'Loading'
successTextstring | ReactNodeButton text when loading successful'Success'
errorTextstring | ReactNodeButton text when loading failed'Error'
typestring'button' | 'submit' | 'reset''button'
classNamestringButton classnames''
styleReact.CSSPropertiesCustom style{}
outlinebooleanEnable outline effectfalse
shadowbooleanEnable shadow effectfalse
roundedbooleanEnable rounded buttonfalse
sizestring'tiny' | 'small' | 'normal' | 'large''normal'
blockbooleanBlock Buttonfalse
messageDurationnumberSuccess/Error message duration in millisecond2000
disabledbooleanDisable buttonfalse
buttonRefReact.Ref | nullButton referencenull
widthstring | nullOverride button widthnull
heightstring | nullOverride button heightnull
animationbooleanButton hover and click animationtrue

Support

You can show your support by starring this project.

Github Star

Contribute

To contribute, see the contributing guide.

License

MIT License

About

3D animated react button component with progress bar.

Topics

Resources

Code of conduct

Contributing

Stars

140 stars

Watchers

4 watching

Forks

Releases

Sponsor this project

Contributors

Languages