Styled-system: Responsive Render: Get active breakpoint as prop?

Created on 30 Jan 2019  Â·  4Comments  Â·  Source: styled-system/styled-system

I wanted to ask if there is a smart way of querying the current breakpoint inside a component? I.e. to not render a sidebar tree that is anyhow never shown on mobile.

Most helpful comment

Alright; I'll close this. At the end of the day, its a _simple_ call of window.matchMedia("(min-width: 400px)").matches (depending on browser support) and just wanted to double check to not miss an implementation on your side.

Anyway: Maybe needless to say, but I really love your libraries and thought process behind their architecture! Thank you very much for contributing your skill in that way to the open source domain.

All 4 comments

You probably want something like this https://github.com/ReactTraining/react-media

Yeah I wanted to avoid another dependency and see, if there’s already something exposed.

styled-system is much lower-level and doesn't involve the DOM or window object, so it doesn't really have anything like this. In a nutshell, styled-system is (propsObject) => styleObject – hope that makes sense!

Alright; I'll close this. At the end of the day, its a _simple_ call of window.matchMedia("(min-width: 400px)").matches (depending on browser support) and just wanted to double check to not miss an implementation on your side.

Anyway: Maybe needless to say, but I really love your libraries and thought process behind their architecture! Thank you very much for contributing your skill in that way to the open source domain.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gregberge picture gregberge  Â·  4Comments

vdesdoigts picture vdesdoigts  Â·  3Comments

fk picture fk  Â·  3Comments

philholden picture philholden  Â·  5Comments

t49tran picture t49tran  Â·  4Comments