[Theme] Provide a function to create the breakpoints property via DI
See original GitHub issueBug report
Right now, to use custom breakpoints, you can just pass extendTheme({ breakpoints: myBreakpointArray })
matching the spec.
However, if you manually pass, you’d be missing the properties defined on the default theme array.
We could provide a function or merge functionality for that into extendTheme
, something like:
interface BreakpointConfig {
[key: string]: string;
sm: string;
md: string;
lg: string;
xl: string;
}
const createBreakpoints = (config: BreakpointConfig) => {
const breakpoints = Object.values(config);
Object.entries(config).forEach(([key, value]) => {
Object.defineProperty(breakpoints, key, { value });
});
return breakpoints;
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Using Breakpoints and Media Queries in Material-UI
In order for us to use the theme and breakpoints, we will provide a function with the theme as a prop. In this...
Read more >Using media queries - CSS: Cascading Style Sheets | MDN
Media queries allow you to apply CSS styles depending on a device's general type (such as print vs. screen) or other characteristics such...
Read more >Breakpoint System Changes in Elementor v3.2.0
Custom breakpoints are used for generating custom CSS based on the values chosen by the user. Prior to v3.2.0, each breakpoint was registered...
Read more >Breakpoints | IntelliJ IDEA Documentation - JetBrains
Breakpoints are special markers that suspend program execution at a specific point. This lets you examine the program state and behavior.
Read more >Breakpoints - Material UI - MUI
CSS media queries are the idiomatic approach to make your UI responsive. The theme provides five styles helpers to do so: theme.breakpoints.up(key) ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A more complex, yet definitely more precise implementation would be based on this, credits to @0kku, but it requires TS 4.1, so we have to wait for next month for that.
It would support those goodies:
possibly, that would lock in to forcing those object keys though; I’m not sure what’s planned in regards of allowing more/less/entirely custom breakpoint names