I'm using a normal Button
from Material-UI
for React
tried adding the following style
button: {
display: 'inline-block',
padding:0
}
to this button
<Button className={classes.button}> I'm a Test Button </Button>
What I obtain is that the padding for the right/left side is correctly set to 0, while the one for top/bottom is not updated, see the attached image.
Is this a bug? Or what's the correct way to achieve this?
EDIT: Material-UI version: v1.0.0-beta.20
To add padding and margin to all React Material-UI components, we can use the Box component. We use Material UI's Box component to add a container with margin and padding. We set the margin on all sides with the m prop and we set the top padding with the pt prop.
if you want to create a space between buttons you can give one button a margin-attribute. will create a 10px space between the two buttons. Show activity on this post. You need Material UI Box Component for this with display="flex" and justifyContent="space-between" .
MUI Grid Remove Padding Here are two steps to completely remove padding from the MUI Grid: Completely remove the spacing prop (or set spacing={0}) Make sure no padding is applied in the sx prop or classes.
Box in Material-UI comes with many predefined properties such as bgcolor (background-color) , display , m (margin) , p (padding) , width , height , and a lot more.
This behavior is caused by the min-height and min-width properties of the root key of the Button element. Setting minHeight: 0
and/or minWidth:0
should fix it:
button: {
display: 'inline-block',
padding:0,
minHeight: 0,
minWidth: 0,
}
This answer is more accurate than @Brunno
<Button sx={{ minHeight: 0, minWidth: 0, padding: 0 }}>My Button</Button>
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