Skip to content

Repository files navigation

apsl-react-native-button

A React Native button component customizable via style props.

Button component screenshotAndroid Button component screenshot

Renders a TouchableOpacity under iOS and a TouchableNativeFeedback under Android.

Install

apsl-react-native-button>=2.5.0 needs React Native 0.25 or higher. apsl-react-native-button<=2.4.2 needs React Native 0.16 or higher.

Install the package:

$ npm i apsl-react-native-button --save

Import the Button component:

importButtonfrom'apsl-react-native-button'

Usage

Provide TouchableWithoutFeedback' props to the component (including style), textStyle's StyleSheet to customize the inner text and a children node to render. You can also provide the isLoading prop that will dim the button and disable it to prevent accidental taps.

<Buttonstyle={{backgroundColor: 'red'}}textStyle={{fontSize: 18}}>
Hello!
</Button>

API

PropTypeDescription
onPressfuncFunction to execute when the onPress event is triggered.
onPressInfuncFunction to execute when the onPressIn event is triggered.
onPressOutfuncFunction to execute when the onPressOut event is triggered.
onLongPressfuncFunction to execute when the onLongPress event is triggered.
textStyleTextStylePropTypesThe StyleSheet to apply to the inner button text.
disabledStyleTextStylePropTypesThe StyleSheet to apply when disabled.
childrenstringThe string to render as the text button.
isLoadingboolRenders an inactive state dimmed button with a spinner if true.
isDisabledboolRenders an inactive state dimmed button if true.
activityIndicatorColorstringSets the button of the ActivityIndicatorIOS or ProgressBarAndroid in the loading state.
backgroundTouchableNativeFeedback.propTypes.backgroundAndroid only. The background prop of TouchableNativeFeedback.

Check the included example for more options.

Similar projects

James Ide's react-native-buttonhttps://github.com/ide/react-native-button/

License

MIT.

About

A React Native button component customizable via props

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages