Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styling NativeBase Inputs

I want to change the border size of an input, the color, etc. For some reason when I stack 2 inputs on top of each other, and I add marginTop to the input underneath, or attempt to resize the inputs, and then center them in the page, the borders on either the left or the bottom disappear.

<View style={styles.formAlign}>
    <Item regular style={styles.email}>
        <Input placeholder='Email' />
     </Item>
     <Item regular style={styles.password}>
         <Input placeholder='Password' />
     </Item>
</View>





email:{
   borderWidth:4,
   color:'red'
},
password:{

},
formAlign:{
    justifyContent:'center',
    alignItems:'center'
},
like image 253
Josh Winters Avatar asked Apr 22 '26 16:04

Josh Winters


1 Answers

tried your code, modified a bit

import React, { Component } from 'react';
import { StyleSheet, View } from 'react-native'
import { Item, Input } from 'native-base';

export default class App extends Component {

  render() {
    return (
      <View style={styles.formAlign}>
        <Item style={styles.email}>
          <Input placeholder='Email' style={styles.input} />
        </Item>
        <Item style={styles.password}>
          <Input placeholder='Password' style={styles.input} />
        </Item>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  email: {
    width: 300,
  },
  password: {
    width: 300,
    marginTop: 15,
  },
  formAlign: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  input: {
    borderWidth: 1,
    borderColor: 'blue'
  }
});

Got this result

Screenshot

like image 174
akhil xavier Avatar answered Apr 25 '26 17:04

akhil xavier



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!