Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
148
rated 0 times [  150] [ 2]  / answers: 1 / hits: 34789  / 6 Years ago, wed, november 21, 2018, 12:00:00

I am trying to remove the padding from a textbox but the problem is it's coming from the Material UI.



I gave padding 0 for all the classes but padding is still not getting removed.



Can you tell me how to remove this padding?



.MuiOutlinedInput-input-1708 {
padding: 18.5px 14px;
}


Here is my code and a sandbox:



https://codesandbox.io/s/m58841kkwp



cssLabel: {
&$cssFocused: {
color: { borderColor: red, padding: 0 }
}
},
cssFocused: { borderColor: red, padding: 0 },
cssUnderline: {
&:after: {
borderBottomColor: red,
padding: 0
}
},
// cssOutlinedInput: {
// &$cssFocused $notchedOutline: {
// borderColor: green
// }
// },

cssOutlinedInput: {
& $notchedOutline: {
//add this nested selector
borderColor: red,
padding: 0
},

&$cssFocused $notchedOutline: {
borderColor: green,
padding: 0
}
},

notchedOutline: { borderColor: red, padding: 0 },

More From » html

 Answers
6

one way to solve it could be to create a useful class and overwrite the styles of the material text field. This way you will make it reusable



I leave the example
https://stackblitz.com/edit/react-textfield-without-padding



Note: I left it with a 5px padding to make it look better as an example. You can customize it so you do not have padding



Useful resources




[#53067] Saturday, November 17, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
quentinaveryb

Total Points: 102
Total Questions: 100
Total Answers: 93

Location: Colombia
Member since Mon, May 2, 2022
2 Years ago
quentinaveryb questions
Thu, Aug 6, 20, 00:00, 4 Years ago
Fri, Jul 17, 20, 00:00, 4 Years ago
Mon, Aug 12, 19, 00:00, 5 Years ago
;