Setting a border for react native TextInput
As of react-native: 0.61.5
you can directly set the borderBottomWidth
on TextInput. Like below in inline style or if you want in separate style object.
style = {{borderBottomWidth : 1.0}}
1 You cannot declare a specific border directly on the TextInput unless multiline is enabled (For example borderLeftWidth
will not work unless multiline={true}
is enabled but borderWidth
will work), but you can just wrap the TextInput in a View and give it a border.
inputContainer: {
borderLeftWidth: 4,
borderRightWidth: 4,
height: 70
},
input: {
height: 70,
backgroundColor: '#ffffff',
paddingLeft: 15,
paddingRight: 15
}
2 You need to declare a backgroundColor
for the TextInput.
3 To make the native keyboard show up, you need to go to the simulator menu and disconnect your hardware. Go to Hardware -> Keyboard -> Connect Hardware Keyboard, toggle it off.
By default the boderWidth will be set for 0. So use borderWidth : 5
defaults for (Top, Right, Bottom, Left).
If you want to asign width individually you have options like,
style = {{
borderStartWidth : 2
borderEndWidth : 3
borderTopWidth : 1
boderLeftWidth: 2
borderRightWidth: 3
borderBottomWidth : 4
}}