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.

Missing disableGutters prop on Container

See original GitHub issue

v4 Container API is missing disableGutters. Padding left and right can’t be disabled on Container through prop as with other components.

  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior 🤔

<Container disableGutters> should remove padding-left and padding-right.

Current Behavior 😯

disableGutters prop is missing in Container

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
oliviertassinaricommented, May 15, 2019

@TheHalcyonSavant I agree, this sounds like a good idea. Bootstrap comes with a default padding logic while tailwind makes you explicitly enable it. a disableGutters prop would be a great tradeoff. What do you think of this change?

diff --git a/packages/material-ui/src/Container/Container.js b/packages/material-ui/src/Container/Container.js
index 72b3878b1..5d272f72c 100644
--- a/packages/material-ui/src/Container/Container.js
+++ b/packages/material-ui/src/Container/Container.js
@@ -10,6 +10,8 @@ export const styles = theme => ({
     marginLeft: 'auto',
     boxSizing: 'border-box',
     marginRight: 'auto',
+  },
+  /* Styles applied to the inner `component` element if `disableGutters={false}`. */
+  gutters: {
     paddingLeft: theme.spacing(2),
     paddingRight: theme.spacing(2),
     [theme.breakpoints.up('sm')]: {
@@ -63,6 +65,7 @@ const Container = React.forwardRef(function Container(props, ref) {
     classes,
     className,
     component: Component = 'div',
+    disableGutters = false,
     fixed = false,
     maxWidth = 'lg',
     ...other
@@ -74,6 +77,7 @@ const Container = React.forwardRef(function Container(props, ref) {
         classes.root,
         {
           [classes.fixed]: fixed,
+          [classes.gutters]: !disableGutters,
           [classes[`maxWidth${capitalize(String(maxWidth))}`]]: maxWidth !== false,
         },
         className,
@@ -100,6 +104,10 @@ Container.propTypes = {
    * Either a string to use a DOM element or a component.
    */
   component: PropTypes.elementType,
+  /**
+   * If `true`, the left and right padding is removed.
+   */
+  disableGutters: PropTypes.bool,
   /**
    * Set the max-width to match the min-width of the current breakpoint.
    * This is useful if you'd prefer to design for a fixed set of sizes

Do you want to submit a pull request? 😃

0reactions
karansahenquerocommented, Jul 29, 2020

love to only remove gutter from right

Read more comments on GitHub >

github_iconTop Results From Across the Web

Missing disableGutters prop on Container #15708 - GitHub
v4 Container API is missing disableGutters. Padding left and right can't be disabled on Container through prop as with other components.
Read more >
How to Get Rid of Padding in Material UI Container Component?
The disableGutters prop removes the padding. Example: import React from "react"; import CssBaseline from "@material-ui/core/CssBaseline"; ...
Read more >
material-ui/core/CHANGELOG.md - UNPKG
We are working on migrating the 48 missing components. ... 1573, - [Container] Add disableGutters prop (#15872) @divyanshutomar.
Read more >
Using Material UI with React Apps: Getting started ... - WorksHub
P.S. In order to disable the margin on both sides of the container, you will set the maxwidth to false and also add...
Read more >
CHANGELOG.old.md - mui/material-ui - Sourcegraph
[Box] Deprecate css prop in favor of sx (#23480) @mnajdova ... [Container] Add disableGutters prop (#15872) @divyanshutomar ...
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