Multiple of the same variants didn't applied properly on responsive styles
See original GitHub issueBug report
Previously I’ve created a discussion in https://github.com/modulz/stitches/discussions/724
Describe the bug
When 2 or more of the same variants are applied on different responsive styles breakpoints, only the last one is applied properly on the component.
To Reproduce
I’ve got this config:
// stitch.config.js
export const { styled } = createCss({
...
media: {
phone: `(min-width: 420px)`,
tablet: `(min-width: 720px)`,
desktop: `(min-width: 1024px)`,
wide: `(min-width: 1536px)`,
},
...
})
And then a Flex component that received a justify props and set it according to its variants
// Flex.js
const Flex = styled('div', {
...,
variants: {
justify: {
start: { justifyContent: "flex-start" },
center: { justifyContent: "center" },
end: { justifyContent: "flex-end" },
between: { justifyContent: "space-between" },
evenly: { justifyContent: "space-evenly" }
},
},
...
})
// usage of Flex
return (
<Flex justify={{
"@initial": "start",
"@phone": "center",
"@tablet": "end",
"@desktop": "between",
"@wide": "end"
}}>
{...items}
</Flex>
)
When I run it, the media query for @tablet
never applied on the <Flex />
You can try this too:
justify={{
"@initial": "start",
"@phone": "center",
"@tablet": "end",
"@desktop": "end",
"@wide": "end"
}}
And the end
variant will only be applied on the @wide
screen. The tablet @tablet
and @desktop
screen still has the center
variant.
Here’s a sandbox demo: https://codesandbox.io/s/stitches-responsive-problem-r43lf
System information
- OS: [macOS]
- Browser: tried on Chrome, Safari TP, and Firefox Nightly
- Version of Stitches: Tried on 0.2.5 and 1.0.0-canary.10
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:18 (4 by maintainers)
Top Results From Across the Web
Multiple of the same variants didn't applied properly ... - GitHub
Describe the bug. When 2 or more of the same variants are applied on different responsive styles breakpoints, only the last one is...
Read more >Responsive Design Tutorial: Media Query Examples & More
Use media queries and pseudo-elements for design and give your mobile users a responsive mobile experience—in pure CSS.
Read more >Responsive images - Learn web development | MDN
Responsive image technologies were implemented recently to solve the problems indicated above by letting you offer the browser several image ...
Read more >Some Tailwind styles not working in production with Next.js
In case anyone is having issues with not updating dom changes accordingly. Check if imports and filenames are written with the same case!...
Read more >Variants - Stitches.dev
() => <Button color="violet">Button</Button>;. A variant accepts the same style object as the base styles. Multiple variants.
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 Free
Top 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
Published under
1.2.6
🎉This is now fixed in a release candidate under the version
1.2.6-0
under a canary tag. Should be pretty stable if you’d like to upgrade now but expect a final release sometime next week once we finish migrating our products to use the updated version.Please, don’t hesitate in providing us with any feedback regarding this release. very much appreciated 🙏