Button #

A basic button component that should render nicely on any platform. Supports a minimal level of customization.

If this button doesn't look right for your app, you can build your own button using TouchableOpacity or TouchableNativeFeedback. For inspiration, look at the source code for this button component. Or, take a look at the wide variety of button components built by the community.

Example usage:

<Button onPress={onPressLearnMore} title="Learn More" color="#841584" accessibilityLabel="Learn more about this purple button" />

Props #

accessibilityLabel string #

Text to display for blindness accessibility features

color color #

Color of the text (iOS), or background color of the button (Android)

disabled bool #

If true, disable all interactions for this component.

onPress function #

Handler to be called when the user taps the button

title string #

Text to display inside the button

You can edit the content above on GitHub and send us a pull request!

Examples #

Edit on GitHub
'use strict'; const React = require('react'); const ReactNative = require('react-native'); const { Alert, Button, View, } = ReactNative; const onButtonPress = () => { Alert.alert('Button has been pressed!'); }; exports.displayName = 'ButtonExample'; exports.framework = 'React'; exports.title = '<Button>'; exports.description = 'Simple React Native button component.'; exports.examples = [ { title: 'Simple Button', description: 'The title and onPress handler are required. It is ' + 'recommended to set accessibilityLabel to help make your app usable by ' + 'everyone.', render: function() { return ( <Button onPress={onButtonPress} title="Press Me" accessibilityLabel="See an informative alert" /> ); }, }, { title: 'Adjusted color', description: 'Adjusts the color in a way that looks standard on each ' + 'platform. On iOS, the color prop controls the color of the text. On ' + 'Android, the color adjusts the background color of the button.', render: function() { return ( <Button onPress={onButtonPress} title="Press Purple" color="#841584" accessibilityLabel="Learn more about purple" /> ); }, }, { title: 'Fit to text layout', description: 'This layout strategy lets the title define the width of ' + 'the button', render: function() { return ( <View style={{flexDirection: 'row', justifyContent: 'space-between'}}> <Button onPress={onButtonPress} title="This looks great!" accessibilityLabel="This sounds great!" /> <Button onPress={onButtonPress} title="Ok!" color="#841584" accessibilityLabel="Ok, Great!" /> </View> ); }, }, { title: 'Disabled Button', description: 'All interactions for the component are disabled.', render: function() { return ( <Button disabled onPress={onButtonPress} title="I Am Disabled" accessibilityLabel="See an informative alert" /> ); }, }, ];