Using the Input
component from React Material UI library (v1.0 beta), I am trying to remove the underline that is rendered using a pseudo element.
const styleSheet = createStyleSheet('searchInput', () => ({
underline: {
'&:before': {
height:0
}
}
}));
const SearchInput = ({ classes, placeholder, value, onChange }) => {
return (
<Input
classes={classes}
placeholder={placeholder}
value={value}
onChange={onChange} />
);
};
When I try to target &:before
though, I get the below error. What is the correct way to override styles and remove this underline?
Warning: Material-UI: the key
.searchInput-underline-1572343541:before
provided to the classes property object is not implemented in Input.You can only overrides one of the following: root,formControl,inkbar,error,input,disabled,focused,underline,multiline,inputDisabled,inputSingleline,inputMultiline,fullWidth,label + .MuiInput-formControl-583691922,.MuiInput-inkbar-171024778:after,.MuiInput-inkbar-171024778.MuiInput-focused-2315792072:after,.MuiInput-error-3674946725:after,.MuiInput-input-3582851417::-webkit-input-placeholder,.MuiInput-input-3582851417::-moz-placeholder,.MuiInput-input-3582851417:-ms-input-placeholder,.MuiInput-input-3582851417::-ms-input-placeholder,.MuiInput-input-3582851417:focus,.MuiInput-input-3582851417::-webkit-search-decoration,label + .MuiInput-formControl-583691922 > .MuiInput-input-3582851417,label + .MuiInput-formControl-583691922 > .MuiInput-input-3582851417::-webkit-input-placeholder,label + .MuiInput-formControl-583691922 > .MuiInput-input-3582851417::-moz-placeholder,label + .MuiInput-formControl-583691922 > .MuiInput-input-3582851417:-ms-input-placeholder,label + .MuiInput-formControl-583691922 > .MuiInput-input-3582851417::-ms-input-placeholder,label + .MuiInput-formControl-583691922 > .MuiInput-input-3582851417:focus::-webkit-input-placeholder,label + .MuiInput-formControl-583691922 > .MuiInput-input-3582851417:focus::-moz-placeholder,label + .MuiInput-formControl-583691922 > .MuiInput-input-3582851417:focus:-ms-input-placeholder,label + .MuiInput-formControl-583691922 > .MuiInput-input-3582851417:focus::-ms-input-placeholder,.MuiInput-underline-892978022:before,.MuiInput-underline-892978022:hover:not(.MuiInput-disabled-265053423):before,.MuiInput-underline-892978022.MuiInput-disabled-265053423:before
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.
2 Answers. Show activity on this post. You can also use the InputProps prop on the TextField component to achieve this by setting the disableUnderline property to true .
The underline can be easily remove by using text-decoration property. The text-decoration property of CSS allows to decorate the text according to requirement. By setting the text-decoration to none to remove the underline from anchor tag.
As per DOC.
disableUnderline prop =>
disableUnderline : boolean
Default Value: false
Details: If true, the input will not have an underline.
There is a property disableUnderline
provided by the DOC, we can directly use that to remove the underline from input element.
Try this:
<Input
disableUnderline={true} //here
classes={classes}
placeholder={placeholder}
value={value}
onChange={onChange} />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With