Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove the arrow and cross that appears for TextField type=“time” material-ui React

I am using the material-ui react textField with type time , I want to remove the arrow and cross that appears on the right on hover and focus.

https://github.com/mui-org/material-ui/blob/master/docs/src/pages/demos/pickers/DatePickers.js

enter image description here

like image 345
Ahmad Jamal Avatar asked May 12 '19 17:05

Ahmad Jamal


People also ask

How do I remove the border for outlined TextField material UI?

The easiest way to remove the border from a Material-UI TextField is to use the 'standard' variant instead of the default 'outlined' variant.

How do I remove the underline in TextField material UI?

You can also use the InputProps prop on the TextField component to achieve this by setting the disableUnderline property to true .


1 Answers

It depends on the browser version, but for most up to date browsers this CSS should do the work.

//remove X
input[type="time"]::-webkit-clear-button {
    display: none;
}

//remove inside of arrows button
input[type="time"]::-webkit-inner-spin-button {
  display: none;
}

//remove outsideof arrows button
input[type="time"]::-webkit-outside-spin-button {
  display: none;
}

So based on your example, you need to edit textField style, so it would look like that

const styles = theme => ({
  textField: {
    marginLeft: theme.spacing.unit,
    marginRight: theme.spacing.unit,
    width: 200,
    "& input::-webkit-clear-button, & input::-webkit-outer-spin-button, & input::-webkit-inner-spin-button": {
            display: "none"
     }
  }
});

But remember that it may not work for every browser. For example, to remove clear button on IE 10 you will need to use this CSS.

input[type="time"]::-ms-clear {
    display: none;
}

You can check list of supported browsers in -webkit docs. Here is an example for -webkit-inner-spin-button

like image 119
Arkadiusz C Avatar answered Sep 28 '22 06:09

Arkadiusz C