Use arrays as values to specify mobile-first responsive styles for CSS-in-JS projects
The main idea of this library is to provide a framework agnostic way to easily enable any property to become responsive.
This is 100% inspired by the awesome work done by Brent Jackson on Rebass.
Install
npm i responsive-styles
Usage
This library was tested against Aphrodite, glamor and emotion so far and they all seem to work nicely.
Aphrodite and React
const breaks = 48 64 80const r = const styles = StyleSheet const className = const App = <div className=className><h1>Aphrodite</h1></div>
glamor and React
const breaks = 48 64 80const r = // A la functional CSSconst padding = const fontSize = // Combine multiple definitions into a single class nameconst colors = const className = ` ` const App = <div className=className><h1>Glamor and Emotion</h1></div>
Examples
If you want to checkout working examples for all libraries, you can download the project, install its dependencies and run:
npm start
API
responsive(propertyOrValues, [maybeValues], [breaks])
propertyOrValues
Type: String
or Array
Property name or an array with all the values for each breakpoint.
maybeValues
Type: Array
Array with all the values for each breakpoint.
breaks
Type: Array
List of breakpoints available, from smallest to largest. You can pass straight up numbers which will default to em
values, or you can simply pass down a list of strings with the units you want.
More
For more examples and details about how the project works, please check our guide.
License
MIT © Rafael Rinaldi