question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Container has padding-right and padding-left even if padding: 0 is added

See original GitHub issue

What package has an issue

@mantine/core

Describe the bug

I’m using the latest version of Mantine and the Container component is receiving padding-right and padding-left properties even when padding: 0 is used in the applied class or in the MantineProvider styles. It only works if px={0} prop is used.

import { MantineProvider, Container } from "@mantine/core";

export default function App() {
  return (
    <MantineProvider
      withGlobalStyles
      withNormalizeCSS
      styles={{
        Container: {
          root: {
            padding: 0 // this has no effect
          }
        }
      }}
    >
      <Container
        sx={{
          width: 500,
          height: 300,
          backgroundColor: "#ff00FF20",
          display: "flex",
          justifyContent: "center",
          alignItems: "center",
          padding: 0 // this has no effect
        }}
        px={0} // this works
      >
        Hello World!
      </Container>
    </MantineProvider>
  );
}

image

In which browser did the problem occur

Chrome and Firefox

If possible, please include a link to a codesandbox with the reproduced problem

https://codesandbox.io/s/agitated-sutherland-3mjowl?file=/src/App.tsx

Do you know how to fix the issue

No

Are you willing to participate in fixing this issue and create a pull request with the fix

Yes

Possible fix

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
rtivitalcommented, Apr 27, 2022

It is not related to Container, set padding prop to 0 instead

1reaction
rtivitalcommented, Apr 8, 2022

You can fix that by setting defaultProps instead of styles on MantineProvider – https://codesandbox.io/s/sweet-waterfall-51pnky?file=/src/App.tsx

This is an issue with styles priority, I’ll try to fix it with one of the next patches.

Read more comments on GitHub >

github_iconTop Results From Across the Web

padding-left - CSS: Cascading Style Sheets - MDN Web Docs
The padding-left CSS property sets the width of the padding area to the left of an element.
Read more >
Remove default padding-left and padding-right in container ...
The problem is that styles.css should follow bootstrap.min.css in the HEAD tag. Once this is done the .container-fluid padding override ...
Read more >
padding | CSS-Tricks
The padding property in CSS defines the innermost portion of the box model, creating space around an element's content, inside of any ...
Read more >
CSS Padding - W3Schools
CSS has properties for specifying the padding for each side of an element: padding-top; padding-right; padding-bottom; padding-left.
Read more >
CSS Margin vs. Padding: What's the Difference? - HubSpot Blog
If you're new to CSS, you might have heard the words margin and padding but aren't quite sure what they mean, or how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found