how to change font size in textInput text when more then 6 char entered in react native?
24,515
You can give conditional style to the TextInput
component.
Example
_onChangeText(text) {
this.setState({ fontSize: text.length > 6 ? 40 : 80 });
}
render() {
return (
// Giving an array of objects to style property can help you to define a -- default value
<TextInput
onChangeText={this._onChangeText.bind(this)}
style={[ {fontSize: 80}, {fontSize: this.state.fontSize} ]}
/>
)
}
Author by
Admin
Updated on July 09, 2022Comments
-
Admin almost 2 years
I want to change the font size of the text that we are entering in textInput only when the charLength more then 6.
the actual font size is 80px, when changing it should be 40 or something like less then it
thanks in advance