Component highly inspired by Button component from react-native-elements. However, it has no external dependencies, so there is no out-of-the-box support for Icon component from react-native-vector-icons

Usage

import { Button } from 'react-native-zero-ui';

<Button
  title="My button"
  styleName="round"
/>


Predefined styles

Some styles are predefined within the plugin. You can add your in your own theme file. Only thing you need is to extend it through zero.ui.Button key

Usage

const theme = {
    'zero.ui.Button': {
        // my global custom styling and props for Button
        '.myStyle': {
            // custom styling for myStyle class
        },
        defaultProps: {
            // default props for Button component
        }
    }
}
<Button styleName="myStyle" />

List of styles

flex

Makes button fill parent flexbox

containerViewStyle: {
  flex: 1,
}

fill

Makes button as wide as the container allows it to be

containerViewStyle: {
  width: '100%',
}

round

Adds borderRadius to button. It also adds borderRadius to all selection modes (highlight, ripple), as well as shadows

rounded: true,
borderRadius: 100,
containerViewStyle: {
  borderRadius: 100,
},
style: {
  borderRadius: 100,
}

Props

All properties are optional

Also, receives all TouchableNativeFeedback (Android) or TouchableOpacity (iOS) props

Reference

Component

component for user interaction

Type Default
Touchable Component TouchableHighlight (ios) or TouchableNativeFeedback (android)

activityIndicatorStyle

add additional styling for ActivityIndicator component used for displaying loading state of the button (optional)

Type Default
object (style) undefined

allowFontScaling

flag that disables or enables font scaling for the button title

Type Default
boolean false

background

prop used for TouchableNativeFeedback

Type Default
object ripple (android API >= 21) or selectable background (API < 21)

backgroundColor

color used for buttons background.

It is recommended to use this prop for configuring background color instead of doing it through styles

Type Default
color undefined

borderRadius

radius used for button border

It is recommended to use this prop instead going through usual styling, because this way shadow and highlight / ripple will be styled as well

Type Default
number 0

buttonStyle

additional styling for button component

Type Default
object (style) none

color

color used for buttons text and loading indicator.

It is recommended to use this prop for configuring color instead of doing it through styles

Type Default
color #ffffff

containerViewStyle

additional styling for button container component

Type Default
object (style) undefined

disabledStyle

additional styling for button component in disabled state

Type Default
object (style) undefined

disabledTextStyle

additional styling for button text in disabled state

Type Default
object (style) undefined

fontFamily

font family used for button text

It is recommended to use this prop for configuring font family instead of doing it through styles

Type Default
string undefined

fontSize

font size used for button text

It is recommended to use this prop for configuring font family instead of doing it through styles

Type Default
number 16

fontWeight

font weight used for button text

It is recommended to use this prop for configuring font weight instead of doing it through styles

Type Default
string undefined

icon

component used for displaying icon in button

Type Default
Component undefined

iconRight

component used for displaying right icon in button

Type Default
Component undefined

large

flag that determines if button has bigger height and extra padding

Type Default
boolean false

loading

prop to display a loading spinner

Type Default
boolean false

loadingRight

prop to display a loading spinner on right size

Type Default
boolean false

outline

flag that determines if button has any outline

Type Default
boolean false

raised

flag that determines if button is displayed as raised (has shadow / elevation)

It is recommended to use this prop for displaying shadow instead of doing it through styles. However, if you need any further customization of the shadow, you need to do it manually

Type Default
boolean false

title

button title (optional)

Type Default
string none

transparent

flag that removes background from button

Type Default
boolean false

underlayColor

same prop from TouchableHighlight with overriden default value

Type Default
color transparent