Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set focus to a materialUI TextField?

Tags:

material-ui

How can I set the focus on a material-ui TextField component?

componentDidMount() {     ReactDom.findDomNode(this.refs.myControl).focus() } 

I have tried above code, but it does not work :(

like image 949
Giles Bradshaw Avatar asked Jun 21 '16 16:06

Giles Bradshaw


People also ask

How do you set focus on TextField?

To give focus to a text field as soon as it's visible, use the autofocus property. TextField( autofocus: true, );


1 Answers

You can use the autoFocus attribute.

<TextField value="some value" autoFocus /> 
like image 121
Antonis Zisis Avatar answered Sep 23 '22 15:09

Antonis Zisis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!