How to underline the TextField only if an error occurs ?
See original GitHub issueTextFields in v0.20.0 used to have an “ErrorText” property, which was very useful to display an error under a textfield and underline it in red at the same time.
<TextField
hintText="Hint Text"
errorText="This field is required"
floatingLabelText="Floating Label Text"
/>
However, TextFields in material-ui@next don’t have that property. In order to display an error and underline in red, a much more complex alternative is used
<FormControl className={classes.formControl} error aria-describedby="name-error-text">
<InputLabel htmlFor="name-error">Name</InputLabel>
<Input id="name-error" value={this.state.name} onChange={this.handleChange} />
<FormHelperText id="name-error-text">Error</FormHelperText>
</FormControl>
Is this the only option ? Is there any other way to achieve it ?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How to underline the TextField only if an error occurs ? #10622
TextFields in v0.20.0 used to have an "ErrorText" property, which was very useful to display an error under a textfield and underline it...
Read more >Is it possible to underline text on JTextField?If Yes, How?
Yes - by adjusting the Font attributes of the component. Font font = textField.getFont(); Map attributes = font.
Read more >Text Field w/Indent Underline Issue - SAP Community
Hello, I have a text field in the report which indents dynamically; this field is underlined. I need the underline to start where...
Read more >TextField - FlutterFlow Docs
By default, a TextField is only one line. So when you type in a long text that won't fit in one line, you'll...
Read more >Text in Compose - Jetpack - Android Developers
TextField allows users to enter and modify text. There are two levels of TextField implementations: TextField is the Material Design implementation. We ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ras24 I think there should be an
error
boolean prop which you can set. Which changes the color of the helperText to red<TextField error />
@ArthurAttout I tried using material-ui@next
If error occur,
helperText
just shown error messege with the gray color not a red color.