In my TextInput
I want to change the size of the font of placeHolder
, I tried like this:
<TextInput
style={styles.email}
value={this.state.email}
placeholder="Email"
placeholderTextColor="red"
//placeholderTextSize = 20px
onChange={this.handleEmailChange.bind(this)}
onBlur={this.onBlur.bind(this)}/>
when I wrote like this color is working for me but size is not working, can any one give me suggestions how to change the size of placeholder Text, any help much appreciated
To change font family for TextInput placeholder in React Native, we can set the fontFamily style of the TextInput . to set the fontFamily property to 'courier' to render the text inputted in the TextInput with Courier.
To change the styling of TextInput placeholder in React Native, we can set the placeholderTextColor prop. to set the placeholderTextColor to 'red' to set the placeholder color of the input to red.
Basically Placeholder provides hints or message about that particular TextInput Component, To add PlaceHolder text in TextInput Component, you need to specify placeholder=" Enter Your First Name" Props inside the TextInput Component.
TextInput component can be created like this.
<TextInput
value={value}
style={value ? styles.input : styles.placeholder}
placeholderTextColor="white"
{...props}/>
There's no way (as far as I remember) to directly change the font size of only the placeholder, since when you change the fontSize using styles, you're changing both, the input fontSize as well as placeholder fontSize. However, there is a way tho...
const [ text, setText ] = useState<string>('');
and then use the state to check whether the input field is empty or not. If it is empty, then change the fontSize as:
{ fontSize: text ? 18 : 12 }
However, it is important to note that even tho this method works, but the delay caused by the re-render is, of course, noticable.
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