What is TouchableOpacity in React Native?

Using TouchableOpacity in React Native, 2-D touch event handlers can be attached to existing view elements such as buttons. This positioned element becomes a UI control that responds to touches in a similar way to the default button elements in iOS and Android apps.

touchableopacity as button in react native

By Live to CodeLive to Code on Apr 25, 2020
//React Native Button element doesn't have style props and offers very 
//few customization. Use TochableXXX elements instead.
//TouchableOpacity works fine

import {
  TouchableOpacity,
  Text,
} from "react-native";

<TouchableOpacity
          style={styles.button}
          onPress={this.onSubmit}
          disabled={!this.state.isFormValid}
        >
          <Text style={styles.btnText}>Add
			</Text>
</TouchableOpacity>

const styles = StyleSheet.create({

  button: {
    width: 200,
    marginTop: 20,
    backgroundColor: "green",
    padding: 15,
    borderRadius: 50,
  },
  btnText: {
    color: "white",
    fontSize: 20,
    justifyContent: "center",
    textAlign: "center",
  },
});

Add Comment

1

touchableopacity

By Arvind JittaArvind Jitta on Mar 27, 2021
 <TouchableOpacity
        style={styles.button}
        onPress={onPress}
      >
        <Text>Press Here</Text>
      </TouchableOpacity>

Add Comment

0

TouchableOpacity is an element that lets you to manipulate the opacity of a React Native element with respect to touch.

Javascript answers related to "touchableopacity"

View All Javascript queries

Javascript queries related to "touchableopacity"

Browse Other Code Languages

CodeProZone