macaron-css / macaron

Compiler-augmented typesafe CSS-in-JS with zero runtime, colocation, maximum safety and productivity
https://macaron.js.org/
MIT License
735 stars 16 forks source link

[Feature] Responsive API #61

Closed dhutaryan closed 1 month ago

dhutaryan commented 1 month ago

Hey, I know that macaron's main aim is to move style generation to compile time. But sometimes we need to make layout responsive using media queries.

Isn't there some way to do this by ease? Literally, media queries are just css. Approach with matchMedia requires much more efforts than just add something like that:

base: {
  display: 'flex',
  selectors: {
    '@media screen and (max-width: 959px)': {
      flexDirection: 'column',
    }
  }
},

vanilla-css allows it https://vanilla-extract.style/documentation/styling/#media-queries

Mokshit06 commented 1 month ago

Hey, the API of vanilla-extract should already work. Basically any API that is supported in vanilla-extract "just works" because under the hood it's using vanilla-extract.

So you should be able to do this:


base: {
  display: 'flex',
  '@media': {
    'screen and (max-width: 959px)': {
      flexDirection: 'column'
    },
  }
},