Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to add border bottom in react native

Tags:

react-native

I am trying to make a registration form.

I created a file named Regform.js under the component directory.

I am unable to get border-bottom for the text Registration

Here is the demo link demo working link

please let me know, where I am doing wrong

enter image description here

Component/Regform.js

import * as React from 'react';    import {     Text,     View,     StyleSheet,      TextInput,    TouchableOpacity     } from 'react-native';     export default class Regform extends React.Component {     render() {      return (       <View>        <Text style={styles.header}> Registration </Text>         <TextInput style = {styles.textinput}       underlineColorAndroid = "transparent"       placeholder = "Enter Your Name"       placeholderTextColor = "#9a73ef"       onChangeText = {this.handleName}/>        <TextInput style = {styles.textinput}       underlineColorAndroid = "transparent"       placeholder = "Enter Your Email"       placeholderTextColor = "#9a73ef"       autoCapitalize = "none"       onChangeText = {this.handleEmail}/>      </View>      );     }    }     const styles = StyleSheet.create({          header: {           fontSize: 36,         alignself: 'self',         color: 'red',         marginBottom: 30,         borderBottomColor: 'red',         borderBottomWidth: 2       },       textinput: {         fontSize: 18,         alignself: 'self',         color: 'black',         marginBottom: 30,         borderBottomColor: 'grey',         borderBottomWidth: 2       }   });  
like image 523
Chaitanya K Avatar asked Aug 22 '18 08:08

Chaitanya K


People also ask

How do I add a border to the bottom in react native?

To add border bottom in React Native, we can add border bottom on the View . to set borderBottom to '1px solid blue' on the View .

How do you set border radius in react native?

Border Radius in React Native The borderRadius property can be set as the style attribute to any element. It takes a value in pixels and assigns that value to the overall border radius of that UI element. By default, the border radius of any element is 0 if you haven't added that style attribute to that element.

What is the use of border in React Native?

Introduction to React Native Border Style React Native Border Style refers to the property which helps in the styling of element’s four borders. The value of this property varies from 1 to 4. Border Style property can be used to specify a border around a box in the uniform style, with 1 value.

How to add border to only bottom side of view in iOS?

So in this tutorial we would going to show Add Border to only Bottom side of View in iOS Android react native application example tutorial using borderBottomWidth and borderBottomColor style attributes. 1. Import StyleSheet and View component in your project. 2. Create a Root View in render’s return block. 3.

How do I set a border around a component?

To set a border, you must first set borderWidth. borderWidth is the size of the border, and it’s always a number. You can either set a borderWidth that applies to the entire component or choose which borderWidth you want to set specifically (top, right, bottom, or left).


1 Answers

It seems borderBottom doesn't work for the Text component. You can either add a View wrapper and supply borderBottom to it or add a TextInput and make editable={false}

<View style={styles.headerWrapper}>     <Text style={styles.header}> Registration </Text>  </View> ...  headerWrapper: {     borderBottomColor: 'red',     borderBottomWidth: 2,     marginBottom: 30, }, header: {     fontSize: 36,     alignSelf: 'auto',     color: 'red',  }, 
like image 146
Pritish Vaidya Avatar answered Sep 21 '22 10:09

Pritish Vaidya