React native Button

 React native Button


A fundamental button part that ought to deliver pleasantly on any stage. Upholds a negligible degree of customization.

React native Button
React native Button



On the off chance that this button doesn't look right for your application, you can assemble your own button utilizing TouchableOpacity or TouchableWithoutFeedback. For motivation, take a gander at the source code for this button part. Or on the other hand, investigate the wide assortment of button parts worked by the local area.


<Button
onPress={onPressLearnMore}
title="Learn React Native"
color="#841584"
accessibilityLabel="Learn about React native"
/>

Example

import React from 'react';
import { StyleSheet, Button, View, SafeAreaView, Text, Alert } from 'react-native';

const Separator = () => (
  <View style={styles.separator} />
);

const App = () => (
  <SafeAreaView style={styles.container}>
    <View>
      <Text style={styles.title}>
        The title and onPress handler are required. It is recommended to set accessibilityLabel to help make your app usable by everyone.
      </Text>
      <Button
        title="Press me"
        onPress={() => Alert.alert('Simple Button pressed')}
      />
    </View>
    <Separator />
    <View>
      <Text style={styles.title}>
        Adjust 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.
      </Text>
      <Button
        title="Press me"
        color="#f194ff"
        onPress={() => Alert.alert('Button with adjusted color pressed')}
      />
    </View>
    <Separator />
    <View>
      <Text style={styles.title}>
        All interaction for the component are disabled.
      </Text>
      <Button
        title="Press me"
        disabled
        onPress={() => Alert.alert('Cannot press this one')}
      />
    </View>
    <Separator />
    <View>
      <Text style={styles.title}>
        This layout strategy lets the title define the width of the button.
      </Text>
      <View style={styles.fixToText}>
        <Button
          title="Left button"
          onPress={() => Alert.alert('Left button pressed')}
        />
        <Button
          title="Right button"
          onPress={() => Alert.alert('Right button pressed')}
        />
      </View>
    </View>
  </SafeAreaView>
);

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    marginHorizontal: 16,
  },
  title: {
    textAlign: 'center',
    marginVertical: 8,
  },
  fixToText: {
    flexDirection: 'row',
    justifyContent: 'space-between',
  },
  separator: {
    marginVertical: 8,
    borderBottomColor: '#737373',
    borderBottomWidth: StyleSheet.hairlineWidth,
  },
});

export default App;

Props


onPress

Handler to be called when the user taps the button.



title

Text to display inside the button. On Android the given title will be converted to the uppercased form.


accessibilityLabel

Text to display for blindness accessibility features.


accessibilityLanguage iOS

A value indicating which language should be used by the screen reader when the user interacts with the element. It should follow the BCP 47 specification.


See the iOS accessibilityLanguage doc for more information.


accessibilityActions

Accessibility actions allow an assistive technology to programmatically invoke the actions of a component. The accessibilityActions property should contain a list of action objects. Each action object should contain the field name and label.


See the Accessibility guide for more information.






I hope You really enjoyed this blog . I try my best to make every thing is easy and helpfull to provide to public .You will get more blog about the Programing project and code . Thanks for visiting my blog if you have any querry related to this you can comment here i will try my best to response you back



Comments