Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing underline style of autocomplete in react material ui component

I want to remove the underline style and change the of the color of it when the text field gets focus in the autocomplete component of react material ui.

I can't seem to find the style to override.

Thanks in advance.

like image 791
JiN Avatar asked May 02 '17 10:05

JiN


People also ask

How do I remove the underline from material UI?

To remove underline from input component with React Material UI, we can set the disableUnderline prop to true . to add the disableUnderline to the Input component. As a result, we wouldn't see the underline of the input now.

How do you clear autocomplete material in UI react?

clearOnBlur={true} helps to clear the value of the autocomplete component when it loses focus.


2 Answers

Minor update to @Liem's response. Just putting the InputProps directly overwrites the InputProps it would use by default, which breaks the component. By merging the disableUnderline with the other InputProps, it should work.

<Autocomplete
   renderInput={
     params => 
       <TextField 
         {...params} 
         InputProps={{...params.InputProps, disableUnderline: true}}
       />
   }
 />
like image 130
rfestag Avatar answered Sep 22 '22 05:09

rfestag


Just adding another answer for material v1. In v1 we have to target the input inside the text field. in order to remove or style the underline

<TextField       
    defaultValue="hello"       
    InputProps={{
       disableUnderline: true
    }}
/>
like image 20
Liem Avatar answered Sep 19 '22 05:09

Liem