loading...

Styled-components media queries

github logo ・1 min read

In company we want to create some styled-component helper to write elegant media-queries and we are arguing which way to choose:

  • with interpolated string like:
      styled.div`
        ${media.mobile`
          color: red
        `}
      `
  • or returning only @media string fragment like (eg. @media (min-width: 100px):
      styled.div`
        ${media.mobile} {
          color: red
        }
      `

What disadvantages / caveats of this two approach?

twitter logo DISCUSS
Classic DEV Post from Feb 14

CSS in JS - have we done something wrong?

Hello folks, its not standard for me article, as I prefer to not get into these kind of discussions,...

Rafal Lesniak profile image

dev.to now has dark theme. 🌝

Go to the "misc" section of your settings and select night theme

P.S. It's the best move you can make for your dev career.