Responsive font size with breakpoints aliases generates media queries in incorrect order
See original GitHub issueBug report
Describe the bug
If I use:
<Heading fontSize={["30px", "45px", "60px", "90px", "180px"]}>
The css generated is in the correct order:
@media screen and (min-width: 80em)
<style>
.css-1yf13mp {
font-size: 180px;
}
@media screen and (min-width: 62em)
<style>
.css-1yf13mp {
font-size: 90px;
}
@media screen and (min-width: 620px)
<style>
.css-1yf13mp {
font-size: 60px;
}
@media screen and (min-width: 400px)
<style>
.css-1yf13mp {
font-size: 45px;
}
If I use:
<Heading fontSize={{ base: "30px", sm: "45px", md: "60px", lg: "90px", xl: "180px" }}>
The css generated is in the wrong order thus the font size applied is not the right one.
@media screen and (min-width: 620px)
<style>
.css-yxyd02 {
font-size: 60px;
}
@media screen and (min-width: 400px)
<style>
.css-yxyd02 {
font-size: 45px;
}
@media screen and (min-width: 80em)
<style>
.css-yxyd02 {
font-size: 180px;
}
@media screen and (min-width: 62em)
<style>
.css-yxyd02 {
font-size: 90px;
}
In that case for instance on a desktop (1920px), it’s the 620px breakpoint size which is applied.
Expected behavior
I’d expect the generated media queries to be in the right order.
System information
- OS: Linux
- Browser (if applies): Chrome (but not tested on other browsers)
- Version of @chakra-ui/core: 1.0.0-rc.3
- Version of Node.js: 12.15.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Responsive Typography With Sass Maps - Smashing Magazine
Let's start by creating a Sass map with key-value pairs — breakpoints as keys and font sizes as corresponding values. ... With mobile-first...
Read more >Responsive typography with chained media queries - Bugsnag
Chaining complex media queries If your project includes Breakpoint, the responsive mixin calls it to generate each of the chained media queries ......
Read more >Responsive Layouts, Fewer Media Queries | CSS-Tricks
Since we are changing the number of items per rows between three values, we need two “breakpoints” (from N to M , and...
Read more >CSS: max-width for @media query not working - Stack Overflow
Have you tried adding the viewport in? <meta name="viewport" content="width=device-width, initial-scale=1">. Working JSFiddle.
Read more >Responsive web design basics
To insert a breakpoint at 600px , create two media queries at the end of your CSS for the component, one to use...
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
My bad I did a simple
yarn add @chakra-ui/theme-tools
. All is working perfectly now, thanks! There is just a small typo in the docs:import { createBreakpoints } from "chakra-ui/theme-tools"
is missing the @ in front ofchakra-ui
.Neat, glad its resolved 😃 Regarding the typo, thanks, yes, we have a PR for that which I should merge anyways.