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.

Unable to customise theme breakpoints

See original GitHub issue
  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

No longer able to customise theme breakpoints.

Expected Behavior 🤔

Be able to import the BreakpointOptions type from core and use it to pass in custom breakpoints to theme.

Steps to Reproduce 🕹

https://codesandbox.io/s/basicalerts-material-demo-forked-7qnte?file=/demo.tsx:9-27

import { BreakpointsOptions } from "@material-ui/core/styles/createBreakpoints";

const getBreakpoints = (theme: CustomerUITheme): BreakpointsOptions => ({
    values: theme.breakpoints,
});

shows error Cannot find module '@material-ui/core/styles/createBreakpoints

there doesn’t appear to be any error passing breakpoints into the createTheme function, and i believe createBreakpoints has moved to the system package. Do we need to install @material-ui/system to be able to use the BreakpointsOptions type?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
eps1loncommented, Jun 10, 2021

I thought that we should support up to level 3, otherwise we are making public the folder structure that we have internally, which with changes like this will break confused

I wanted to say that we should make it public via public path. So re-export it from something at level 2 or 3. Not tell people to export from level >=4

1reaction
oliviertassinaricommented, Jun 9, 2021

The proposed patch looks great. I would even not make BreakpointValues public but and inline it for consistency with the other keys:

diff --git a/packages/material-ui-system/src/createTheme/createBreakpoints.d.ts b/packages/material-ui-system/src/createTheme/createBreakpoints.d.ts
index 6389985a74..3a9544acb7 100644
--- a/packages/material-ui-system/src/createTheme/createBreakpoints.d.ts
+++ b/packages/material-ui-system/src/createTheme/createBreakpoints.d.ts
@@ -6,12 +6,11 @@ export type Breakpoint = OverridableStringUnion<
   'xs' | 'sm' | 'md' | 'lg' | 'xl',
   BreakpointOverrides
 >;
-export type BreakpointValues = { [key in Breakpoint]: number };
 export const keys: Breakpoint[];

 export interface Breakpoints {
   keys: Breakpoint[];
-  values: BreakpointValues;
+  values: { [key in Breakpoint]: number };
   up: (key: Breakpoint | number) => string;
   down: (key: Breakpoint | number) => string;
   between: (start: Breakpoint | number, end: Breakpoint | number) => string;

Regarding the side questions. @material-ui/core/styles/createBreakpoints was never allowed as an import path (AFAIK). It’s private. With #26254 we can enforce to make them unreachable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to get custom breakpoints in theme - Stack Overflow
So I would like to get my custom breakpoint values from within the createMuiTheme . I've tried the following but it doesn't work, ......
Read more >
theme.breakpoints.down method does not support custom ...
Steps: create a theme with custom breakpoints; use theme.breakpoints.down(customBreakpoint) or other affected functions. Context.
Read more >
Allow sub-theme to alter breakpoints of base theme - Drupal
To be clear, I want to simply change the min/max width pixel values for xs, sm, md, and lg, not define any completely...
Read more >
Fixing Your Responsive Navigation Menu in Divi
Creating a responsive navigation menu that looks great on all screen ... Thankfully, Divi's theme customizer allows you to customize the ...
Read more >
Changing breakpoint for the mobile menu - WordPress.org
[This thread is closed.] Hello! I'm trying to change the breakpoint where the menu goes to the mobile menu in a child theme,...
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