• Stars
    star
    531
  • Rank 83,526 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 2 years ago

Reviews

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

Repository Details

A Beautiful, Customizable React Native Button component for iOS & Android

Build Status npm npm

React Native Button component

React Native Button component for iOS & Android.

Example Example

Provided Components

This library provided the following button components:

ButtonComponent
CircleButton
RoundButton
RectangleButton

Installation

  1. npm install --save react-native-button-component
  2. react-native link react-native-button-component
Note

If you didn't see this item libART.a under the Link Binary With Libraries or you get this error No component found for view with name "ARTSurfaceView" Please open Xcode project and add libART.a under Build Phases -> Link Binary With Libraries

The detailed steps:
  1. Open Xcode project
  2. Build Phases -> Link Binary With Libraries
  3. Click the + button and Click Add Other...
  4. Open with node_modules/react-native/Libraries/ART/ART.xcodeproj
  5. Click the + and select the libART.a and click Add

Some Simple Examples

One State Button
Multiple States Button
Spinner Button
Progress Button
Circle Button

Documents

Props & Button Options
Options for Progress Button
Options for Spinner Button
Options for Circle Button

Usage - Basic

Button with one state

import ButtonComponent, { CircleButton, RoundButton, RectangleButton } from 'react-native-button-component';

// You can use CircleButton, RoundButton, RectangleButton to instead ButtonComponent
<ButtonComponent
  onPress={() => {}}
  image={require('button-image.png')}
  text="Button"
>
</ButtonComponent>

Button with multiple states

import ButtonComponent, { CircleButton, RoundButton, RectangleButton } from 'react-native-button-component';

// You can use CircleButton, RoundButton, RectangleButton to instead ButtonComponent
<ButtonComponent
  buttonState={this.state.buttonState} // "upload" or "uploading"
  states={{
    upload: {
      onPress: () => {
        this.imageUploader.upload();
        this.state.setState({ buttonState: 'uploading' });
      },
      image: require('upload-image.png'),
      text: 'Upload Image',
    },
    uploading: {
      onPress: () => {
        this.imageUploader.cancelUpload();
        this.state.setState({ buttonState: 'upload' });
      },
      spinner: true,
      text: 'Uploding Image...',
    },
  }}
>
</ButtonComponent>

Usage - With Your Configurations

Button with one state

<ButtonComponent
  text="Button"
  type="primary"
  shape="rectangle"
  backgroundColors={['#4DC7A4', '#66D37A']}
  gradientStart={{ x: 0.5, y: 1 }}
  gradientEnd={{ x: 1, y: 1 }}
  height={80}
  onPress={() => {}}
  image={require('button-image.png')}
>
</ButtonComponent>

Button with multiple states - different config for different states

import ButtonComponent, { CircleButton, RoundButton, RectangleButton } from 'react-native-button-component';

// You can use CircleButton, RoundButton, RectangleButton to instead ButtonComponent
<ButtonComponent
  buttonState={this.state.buttonState} // "upload" or "uploading"
  gradientStart={{ x: 0.5, y: 1 }}
  gradientEnd={{ x: 1, y: 1 }}
  states={{
    upload: {
      text: 'Upload Image',
      backgroundColors: ['#4DC7A4', '#66D37A'],
      image: require('upload-image.png'),
      onPress: () => {
        this.imageUploader.upload();
        this.state.setState({ buttonState: 'uploading' });
      },
    },
    uploading: {
      text: 'Uploding Image...',
      gradientStart: { x: 0.8, y: 1 },
      gradientEnd: { x: 1, y: 1 },
      backgroundColors: ['#ff4949', '#fe6060'],
      spinner: true,
      onPress: () => {
        this.imageUploader.cancelUpload();
        this.state.setState({ buttonState: 'upload' });
      },
    },
  }}
>
</ButtonComponent>

Button with multiple states - one config for different states

<ButtonComponent
  buttonState={this.state.buttonState} // "upload" or "uploading"
  gradientStart={{ x: 0.5, y: 1 }}
  gradientEnd={{ x: 1, y: 1 }}
  backgroundColors={['#4DC7A4', '#66D37A']}
  states={{
    upload: {
      text: 'Upload Image',
      image: require('upload-image.png'),
      onPress: () => {
        this.imageUploader.upload();
        this.state.setState({ buttonState: 'uploading' });
      },
    },
    uploading: {
      text: 'Uploding Image...',
      spinner: true,
      onPress: () => {
        this.imageUploader.cancelUpload();
        this.state.setState({ buttonState: 'upload' });
      },
    },
  }}
>
</ButtonComponent>

License

MIT

More Repositories

1

react-native-modals

A react native modals library. Swipeable. Highly customizable. Support multi modals & Support custom animation. For IOS & Android.
JavaScript
2,174
star
2

ftp

Python FTP Server & Client
Python
124
star
3

react-native-card-view

A react native card component
JavaScript
106
star
4

react-native-onboarding-component

React Native App Onboarding Views component for IOS and Android
JavaScript
94
star
5

myDesktop

python remote desktop (like VNC)
Python
88
star
6

react-native-dialog-component

A react native dialog component support custom animation for IOS & Android.
JavaScript
81
star
7

react-native-action-sheet-component

React Native Action Sheet Component for iOS & Android.
JavaScript
61
star
8

react-native-carousel-component

React Native Carousel Component for IOS & Android
JavaScript
61
star
9

react-native-animated-overlay

A Simple React Native Animated Overlay for iOS & Android.
JavaScript
31
star
10

http-request-capture

A simple tool for capturing http requests.
Python
22
star
11

cursesDialog

python curses dialog library
Python
9
star
12

react-native-modal-component

React Native Modal for IOS and Android
JavaScript
8
star
13

PyQt-ProgressDialog

Python QT Progress Dialog
Python
8
star
14

PyMail

Python curses email client
Python
6
star
15

ng-places-autocomplete

a fancy places autocomplete angular directive, support google, baidu places autocomplete
JavaScript
3
star
16

myTrelloA

JavaScript
3
star
17

algo

JavaScript
2
star
18

dualshock4

Cool animation with react native
JavaScript
2
star
19

parallax

Parallax effect in mobile with react native.
JavaScript
2
star
20

jacklam718.github.io

CSS
1
star
21

gini-coding-challenge

Live coding challenge interview
JavaScript
1
star
22

react-native-menus

JavaScript
1
star
23

crypto-app

Real-time crypto price tracker app
JavaScript
1
star
24

fullstack-web-demo

coding test for a full stack developer position
JavaScript
1
star
25

react-native-segmented-control

1
star
26

react-native-dropdown-list

1
star
27

algorithms

1
star
28

interact-with-mobile

HTML
1
star
29

leetcode

JavaScript
1
star
30

autocompletejs

A simple and extendable and no jQuery required JavaScript library for autocomplete
JavaScript
1
star
31

redux-api-middleware

"WIP" - A redux middleware for api calls, response and error handling.
JavaScript
1
star
32

sMitm

A simple `man in the mindle`
Python
1
star
33

webpack

JavaScript
1
star
34

flexy-photo

JavaScript
1
star
35

angular-datepicker

JavaScript
1
star