npm install react-character-counter --save
This Component only works for controlled inputs
import CharacterCounter from 'react-character-counter'
state = {
name: ''
}
<CharacterCounter value={this.state.name} maxLength={120} >
<input type='text' maxLength={120} value={this.state.name}>
</CharacterCounter>
{
value: String, Required
maxLength: Number, Required
wrapperStyle: Object, Optional
characterCounterStyle: Object, Optional
overrideStyle: Boolean, Optional
}
<CharacterCounter
value={this.state.name}
maxLength={120}
wrapperStyle={{position: 'relative'}}
characterCounterStyle={{color: 'orange'}}
>
<input type='text' maxLength={120} value={this.state.name}>
</CharacterCounter>
<CharacterCounter
value={this.state.name}
maxLength={120}
wrapperStyle={{position: 'relative'}}
characterCounterStyle={{
position: "absolute",
fontSize: "12px",
fontWeight: "600",
top: "14px",
right: "0px"
}}
>
<input type='text' maxLength={120} value={this.state.name}>
</CharacterCounter>
{
position: "relative"
}
{
position: "absolute",
fontSize: "12px",
fontWeight: "600"
}