Sometimes, we want to align text input correctly in React Native.
In this article, we’ll look at how to align text input correctly in React Native.
How to align text input correctly in React Native?
To align text input correctly in React Native, we set the textAlignVertical
style to 'top'
.
For instance, we write
<TextInput
style={{
flex: 1,
width: "100%",
height: 150,
color: "#FFF",
textAlignVertical: "top",
}}
multiline
numberOfLines={10}
/>;
to set the textAlignVertical
style of the TextInput
component to 'top'
so that it takes input from the top left corner.
We make the TextInput
take multiple lines of input with the multiline
prop.
And we set the numberOfLines
prop to make the input accept 10 lines of input.
Conclusion
To align text input correctly in React Native, we set the textAlignVertical
style to 'top'
.