Responsive Styles
How to configure breakpoints and apply variants responsively.
Often when working on responsive layouts, it's useful to adjust styles along a singular dimension – such as font-size, margin, padding, and width. Instead of manually managing media queries and adding nested style objects throughout a code base, System Props offers a convenient shorthand syntax for adding responsive styles. While this syntax can seem odd at first, it can become a powerful way to manage responsive typography and layouts.
The responsive syntax works the same as Styled System.
All system props support the responsive syntax. For it to work, you must have a breakpoints
property in your theme. If your breakpoints are defined as an object, the responsive syntax should be an object, where each key corresponds to one of the keys in your breakpoints. Any key that does not correspond to a key in your breakpoints, its value will apply at all screen sizes. If your breakpoints are defined as an object or an array, you can use the responsive syntax as an array, where the first index applies at all breakpoints, the second at the first breakpoint, and so on.
What it does
This shortcut is an alternative to writing media queries out by hand. Given the following:
Using System Props with a CSS-in-JS library will generate something like the following CSS: