Skip to content

Instantly share code, notes, and snippets.

@nikosantis
Created March 25, 2020 21:23
Show Gist options
  • Save nikosantis/b4b0684fe82bcaedb4e278915f0b1968 to your computer and use it in GitHub Desktop.
Save nikosantis/b4b0684fe82bcaedb4e278915f0b1968 to your computer and use it in GitHub Desktop.
Media queries for Styled Components
import { css } from 'styled-components'
const breakpoints = {
xs: '480px',
sm: '768px',
md: '992px',
lg: '1200px'
}
export const MQ = Object.keys(breakpoints).reduce((accumulator, label) => {
accumulator[label] = (...args) => css`
@media (min-width: ${breakpoints[label]}) {
${css(...args)}
}
`
return accumulator
}, {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment