9 February 2020

Button With Rounded Corner example in react native

  • Create Components folder under src folder
  • Add ButtonWithRoundedCorner.js file and add below Code
import React from "react";
import { TextViewButtonStyleSheet,TouchableHighlight } from "react-native";

const ButtonWithRoundedCorner = () => {
  return (
    <View>
      <Text>Button With Rounded Corner example</Text>
      <TouchableHighlight  style={styles.ButtonStyleClass} >
        <Text style={styles.submitText} >Submit</Text>
      </TouchableHighlight>
    </View>
  );
};
export default ButtonWithRoundedCorner;

const styles = StyleSheet.create({
  ButtonStyleClass: {
    marginRight:40,
    marginLeft:40,
    marginTop:10,
    paddingTop:20,
    paddingBottom:20,
    backgroundColor:'#68a0cf',
    borderRadius:10,
    borderWidth: 1,
    borderColor: '#fff'
  },
  submitText:{
    color:'#fff',
    textAlign:'center',
}
});
  • Open App.js file and update code as below
import React from 'react';
import {  Text,View,StyleSheet } from 'react-native';
 import ButtonWithRoundedCorner from './src/Component/ButtonWithRoundedCorner'

 const  App=()=> {
  return (
    <View style={styles.container}>
      <ButtonWithRoundedCorner/>
    </View>
  );
}
export default App;

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    paddingTop:80
  },
});


Output:


No comments:

Post a Comment