Reputation: 2450
One short question.
Is there a way to centralize text in react-native Textinput
?
Here is the markup in jsx:
<TextInput style={styles.input} placeholder="Your Account" />
In styles.input, just try to add textAlign:"center"
, it's not working.
And same as add alignAlign to the markup as an attribute. Could anybody do me a favor? Thx.
Upvotes: 43
Views: 78340
Reputation: 1143
You should use the inputText props to align text to center as below
textAlign={'center'}
And it will look like
<TextInput style={styles.input} textAlign={'center'} placeholder="Your Account" />
Upvotes: 84
Reputation:
The android-only textAlignVertical
may also be a necessary component of the solution. See also: How to align text input correctly in react native?
Upvotes: 3
Reputation: 938
This bug has been around for a while already, but it looks like a fix will be merged soon: https://github.com/facebook/react-native/pull/772
Upvotes: 6