Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container queries support #1143

Open
gokulsgr opened this issue Feb 23, 2023 · 2 comments
Open

Container queries support #1143

gokulsgr opened this issue Feb 23, 2023 · 2 comments

Comments

@gokulsgr
Copy link

Could you please add support for container queries like we have for media queries?

media: {
    bp1: "(min-width: 520px)";
    bp2: "(min-width: 900px)";
    bp3: "(min-width: 1200px)";
    bp4: "(min-width: 1800px)";
    motion: "(prefers-reduced-motion)";
    hover: "(any-hover: hover)";
    dark: "(prefers-color-scheme: dark)";
    light: "(prefers-color-scheme: light)";
}
@jonmumm
Copy link

jonmumm commented Jun 3, 2023

Any known workarounds to be able to use container queries in stitches at all?

@wbobeirne
Copy link

You can use container queries like other @ queries by just including it as a key, e.g.

css({
  "@supports (display: grid)": {
    // styles
  },
  "@container (min-width: 700px)" {
    // styles
  }
})

However, one problem I'm seeing is that https://github.com/stitchesjs/stitches/blob/2876c6fe835c4d499e87a8e53a5c586395e40358/packages/core/src/convert/toResolvedMediaQueryRanges.js is trying to manipulate the values, so sometimes you end up with an invalid query. For instance, the following input gets the following output:

css({
    '@container (max-width < 200px)': {
        color: 'red',
    },
})
@container (max-max-width:199.9375px){color:red}

but you can still get usable queries if you choose values that work well with this rewriter. However, it'd be nice if it were updated to account for valid @container queries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants