Performant, extendable, highly customisable, production ready React Component that renders an animated basic set of UI buttons
npm install react-awesome-button !NPM
react-awesome-button is a performant, extendable, highly customisable, production ready React Component that renders an animated set of 3D UI buttons. Bundled together with a _social share_ and _progress enabled_ components.
- 60fps 3D animated button
- Animated progress button
- Social icons and network specific share methods
- OnPress ripple effect
- Look and feel customisable and extendable in two ways: via CSS custom properties or SASS variables and lists (scss config file).
- Use it with CSSModules or \\Plain CSS
Checkout the live demo with the CSS customizer at awesome-button.caferati.me.
Import it directly into your Figma project.
You can run the storybook locally on 6006 by cloning this repository and running npm run storybook
```
npm install --save react-awesome-button
`jsx
import { AwesomeButton } from 'react-awesome-button';
import 'react-awesome-button/dist/styles.css';
function Button() {
return
}
`
`jsx
import { AwesomeButton } from 'react-awesome-button';
import AwesomeButtonStyles from 'react-awesome-button/src/styles/styles.scss';
function Button() {
return (
Button
);
}
`
Renders the component with a button HTML tag and an onPress prop called on animation release.
`jsx
import { AwesomeButton } from 'react-awesome-button';
import AwesomeButtonStyles from 'react-awesome-button/src/styles/styles.scss';
function Button() {
return (
type="primary"
onPress={() => {
// do something
}}>
Button
);
}
`
Render the component with an anchor HTML tag setting the href attribute.
`jsx
import { AwesomeButton } from 'react-awesome-button';
import AwesomeButtonStyles from 'react-awesome-button/src/styles/styles.scss';
function Button() {
return (
type="primary"
href="https://google.com">
Button
);
}
`
| Attribute | Type | Default | Description |
| :------------- | :----------: | :-------: | :------------------------------------------------------------------------------------------------------- |
| type | string | primary | Render a specific button type, styled by the .scss type list |string
| size | | auto | Render a specific button size, styled by the .scss size list |node
| element | | null | Overwrites the default container element renderer, useful for using it with react-router Link component. |bool
| disabled | | false | Render the disabled button |bool
| visible | | true | Toggle button visibility |bool
| ripple | | false | Sets up the button with the onPress ripple effect |bool
| placeholder | | true | Should render the animated placeholder on empty children |function
| onPress | | null | Default pressRelease event function |function
| onPressed | | null | Event function triggered only on full button press |function
| onReleased | | null | Event function triggered on button full animation release |function
| onMouseDown | | null | Event function coupled with the element's onMouseDown |function
| onMouseUp | | null | Event function coupled with the element's onMouseUp |string
| href | | null | Forces the button to be rendered on an anchor container and sets the href to the specified value |string
| className | | null | Adds a className to the button container element |object
| style | | null | Passes a style object to the container element |object
| containerProps | | null | Exposes an option for freely adding props to the button container element |object
| cssModule | | null | Accepts a css module configuration from the themed module.scss files |string
| target | | null | When used together with href renders an anchor with a specific target attribute |React.Node
| before | | null | Render a node before the main content span container; useful for setting icons |React.Node
| after | | null | Render a node after the main content span container; useful for setting icons |string
| between | | null | Sets the content elements relation to space-between; useful for setting icons |bool
| active | | false | When set to true activates the pressIn animation |
Checkout this example live on the storyboard.
`jsx
import { AwesomeButtonProgress } from 'react-awesome-button';
import AwesomeButtonStyles from 'react-awesome-button/src/styles/styles.scss';
function Button() {
return (
type="primary"
onPress={(event, release) => {
// do a sync/async task then call release()`
}}>
Button
);
}
Being a wrapper on the AwesomeButton component, it accepts its props plus the following ones.
| Attribute | Type | Default | Description |
| :----------- | :--------: | :--------: | :------------------------------------------------------------------------------- |
| onPress | function | null | Default onPress function returning the event and a button release strategy |string
| loadingLabel | | Wait .. | Progress button loading label text |string
| resultLabel | | Success! | Progress button success label text |number
| releaseDelay | | 500 | Delay for releasing the button after the progress animation |
If nothing is passed on the sharer prop, the component automatically gets the page's own title and og:image properties; otherwise, it's setup by the sharer.
`jsx
import { AwesomeButtonSocial } from 'react-awesome-button';
import AwesomeButtonStyles from 'react-awesome-button/src/styles/styles.scss'
function Button() {
return (
type="facebook"
sharer={{
url="https://caferati.me"
}}
>
Button
);
}
`
`jsx
import { AwesomeButtonSocial } from 'react-awesome-button';
import AwesomeButtonStyles from 'react-awesome-button/src/styles/styles.scss'
function Button() {
return (
type="whatsapp"
sharer={{
phone: '############',
message: 'Whatsapp init message'
}}
>
Button
);
}
`
Being a wrapper on the AwesomeButton component, it accepts its props plus the following ones.
| Attribute | Type | Default | Description |
| :------------- | :--------------------: | :-----: | :------------------------------------------------------------------------------------------------------------------------------------------ |
| type | string | null | Render a button type (Facebook, Instagram, Twitter, Github, Youtube, Linkedin, Pinterest, Reddit, Messenger, Whatsapp) |bool
| icon | or Dimensions | true | Setting to false avoids icon rendering; if the dimensions type is passed in {width: number, height: number}, configures the button size |string
| sharer.url | | null | Url string to be used on the sharer |string
| sharer.image | | null | Image url to be rendered on the sharer |string
| sharer.message | | null | Message string to be rendered on the shared post |string
| sharer.phone | | null | Phone number to be used when using the Whatsapp sharer type |string
| sharer.user | | null | Username to be redirected when using the Messenger` sharer type |
Checkout the React Native version of the Awesome Button UI Component at rcaferati/react-native-really-awesome-button

#### Rafael Caferati
- Checkout my Full-Stack Web Developer Website
- Other open source projects @ Code Laboratory
- A scope of my work @ Web Developer Portfolio
MIT. Copyright (c) 2019 Rafael Caferati.