2.29.1 • Published 8 years ago

sp-react-native-iconbutton v2.29.1

Weekly downloads
5
License
MIT
Repository
github
Last release
8 years ago

sp-react-native-iconbutton

A React Native button that can also have an icon within it through the iconProps property.

It works both WITH an icon AND without so it can cover all your button needs.

Renders a TouchableOpacity under iOS and a TouchableNativeFeedback under Android.

Install

sp-react-native-iconbutton needs React Native 0.16 or higher.

Install the package:

$ npm i sp-react-native-iconbutton --save

Import the Button component:

import Button from 'sp-react-native-iconbutton'

###Caution: This library is now compatible for react-native 29 and onwards. Thats because it uses the ActivityIndicator which does not exist in previous versions of react-native. If you wish to run it in previous react-native versions you will have to use the branch called pre29.

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.

<Button
    style={{backgroundColor: '#3D5B96', height:60, borderRadius: 4, borderWidth: 1, borderColor: 'rgba(0,0,0,0.2)'}}
    textStyle={{color: 'white', textAlign: 'center'}}
    iconProps={{name: "facebook",size:25, color: "white"}}
    iconStyle={{paddingHorizontal:20}}
>
    Login with Facebook
</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.
customIconfuncA function that returns a custom React element that will serve as the icon. (If you use that, you should NOT use iconProps or iconStyle)
iconContainerStyleViewStylePropTypesThe StyleSheet to apply to the view that contains our icon be it a custom icon or a default (FontAwesome) icon.
iconStyleViewStylePropTypesThe StyleSheet to apply to the inner button text. (If you use that, you should NOT use customIcon)
iconPropsObjectIf you pass iconProps you're actually telling the Button to create a FontAwesome icon, and you then pass those props to that icon. The properties to pass to your (FontAwesome) icon. You can pass any prop that you could pass on react-native-vector-icons (If you use that, you should NOT use customIcon)
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.

License

MIT.

2.29.1

8 years ago

2.29.0

8 years ago

2.4.15

8 years ago

2.4.14

8 years ago

2.4.13

8 years ago

2.4.12

8 years ago

2.4.11

8 years ago

2.4.10

8 years ago

2.4.9

8 years ago

2.4.8

8 years ago

2.4.7

8 years ago

2.4.6

8 years ago

2.4.5

8 years ago

2.4.4

8 years ago

2.4.3

8 years ago