11

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.

JiN
  • 818
  • 1
  • 7
  • 14
  • can you share the link or code? – Sahil Dhir May 02 '17 at 11:01
  • http://www.material-ui.com/#/components/auto-complete Have a look at the simple example.. I don't want that underline on the textfield.. Rather i want to use my own custom style. – JiN May 02 '17 at 11:02

3 Answers3

33

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}}
       />
   }
 />
rfestag
  • 1,913
  • 10
  • 20
18

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
    }}
/>
Liem
  • 730
  • 8
  • 15
2

You can accomplish this using the <TextField/> props that are rendered to the <AutoComplete/> component. Because <AutoComplete /> uses the <TextField/> you have access to those props. So you actually have two ways of removing the underline of the autocomplete. Unfortunately this is undocumented in the Material-UI docs for autocomplete.

<AutoComplete underlineStyle={{display: 'none'}}>

or

<AutoComplete underlineShow={false}>

edit: This answer is relevant to older versions of Material UI. This answer does not work for version 1.0 or higher.

CaseyC
  • 1,453
  • 14
  • 23