To capitalize the first letter of a string in React:Use the charAt() method to get the first letter of the string. Call the toUpperCase() method on the letter. Use the slice() method to get the rest of the string. Concatenate the results.
create({ title: { fontSize: 18, textTransform: 'uppercase', }, }); If you want to capitalize the first letter of each word then you should use 'capitalize' value of textTransform style prop.
To force an input field to uppercase in React:Use the toUpperCase() method to uppercase the field's value, e.g. event. target. value. toUpperCase() .
TextInput has autoCapitalize
to handle this.
`autoCapitalize enum('none', 'sentences', 'words', 'characters')`
For example try like this:
<TextInput
placeholder=""
placeholderTextColor='rgba(28,53,63, 1)'
autoCapitalize='none'
value='test'
/>
Make sure that the property autoCorrect
is false
. This way it will not capitalize the first email character. Also setting the keyboardType
to email-address
shows the keyboard with an @ option accessible. That's how I would do:
<TextInput
textContentType='emailAddress'
keyboardType='email-address'
autoCapitalize='none'
autoCorrect={false}
autoCompleteType='email'
/>
If you have an issue with TextInput
to make all letters uppercase then you can use autoCapitalize = 'characters'
and if you want only first characters to be uppercase then use autoCapitalize = 'words'
. However, make sure you do not set the keyboard type property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With