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.

[Grid] Add support for new breakpoints

See original GitHub issue

I need to add xxl breakpoint, I followed the docs to create a custom breakpoint, however, when i use the Grid component it gives me a TS warning.

using the "@material-ui/core": "^5.0.0-alpha.33"

<Grid item xxl={1} xl={2}>

here is the custom breakpoint code


// override the BreakpointOverrides  interface
declare module '@material-ui/core/styles' {
  interface BreakpointOverrides {
    xs: true;
    sm: true;
    md: true;
    lg: true;
    xl: true;
    xxl: true;
  }
}


const baseOptions: ThemeOptions = {
  breakpoints: {
    keys: ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'],
    values: {
      xs: 0,
      sm: 640,
      md: 768,
      lg: 1024,
      xl: 1280,
      xxl: 1536,
    },
  },
};

Please advice me where i’m doing wrong.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:10
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

5reactions
mnajdovacommented, Apr 22, 2022

I’ve just did a review, sorry for the delay. It’s important that we resolve https://github.com/mui/material-ui/pull/31998#pullrequestreview-949788800 before moving forward.

5reactions
robphoenixcommented, Apr 22, 2022

For anyone else banging their head against a brick wall that has ended up here looking for a workaround to this issue, this is what ended up working for me…

<Grid
    item
    columns={{ mobile: 4, tablet: 8, desktop: 12 }}
    {...{ mobile: 4, tablet: 4, desktop: 8 }}
    >

On every Grid component you have to specify the columns you want for your custom breakpoints (columns={{ mobile: 4, tablet: 8, desktop: 12 }}), so it’ll be worth creating a wrapper. You then have to add a prop with the name of your breakpoint and the value you want, ie desktop={8}, however TypeScript doesn’t like this as these props don’t exist on the MuiGrid component, which is why I’ve used {...{ mobile: 4, tablet: 4, desktop: 8 }}. This will also work as expected if you only specify some of the breakpoints; {...{ tablet: 4 }}.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Post Grid – Breakpoint Options - WordPress.org
Hello Livemesh-Team,. the post-grid element doesn´t seem to have options to customize the breakpoints for the responsive views.
Read more >
Breakpoints · Bootstrap v5.0
Bootstrap includes six default breakpoints, sometimes referred to as grid tiers, for building responsively. These breakpoints can be customized if you're using ...
Read more >
Add custom grid breakpoint - Material Design for Bootstrap
Yes, I have included all the scss files in my project. Still, couldn't change or add a new breakpoint. I have found similar...
Read more >
How To Use CSS Breakpoints For Responsive Design
In this approach, we simply set a breakpoint at each point where the content layout is misaligned. This method greatly simplifies the ...
Read more >
Realizing common layouts using grids - CSS - MDN Web Docs
Something to note as we create this layout is that we haven't needed to explicitly position every element on the grid at each...
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