React Emotive
A wrapper for React of the 'Emotive' css-in-js library.
; const MyComp = Styled; const OtherComp = <MyComp textColor=ColorWHITE bgColor=ColorBLUE> Emotive is cool with React </MyComp>;
Install
Install with Npm
npm install --save react-emotive
or Yarn
yarn add react-emotive
Index
Usage
Styled components
Use the Styled
object to create custom styled React components.
Every HTML element is avaiable as a method
const BasedOnTable = Styled;
You can also extends another component using Styled.component
method
const BasedOnComponent = Styled;
Emotive
Every emotive
object is re-exported to be directly available from react-emotive
.
Emotive object | Content |
---|---|
Css |
Property objects |
Method |
Methods |
Length |
Length and percentage units methods |
Angle |
Angle units methods |
Time |
Time units methods |
Frequency |
Frequency units methods |
Resolution |
Resolution units methods |
Keyword |
Keywords constants |
Color |
Colors constants |
Unit |
Units constants |
Property |
Properties name constants |
Query |
Media Queries |
For a complete guide to these objects, see Emotive User Guide
Props
You can easily create dynamic styled components based on component props:
const MyComp = Styled;
Media Query
It is possible to create custom wrappers based on media queries. Properties specified inside them will be considered only when the corresponding conditions are satisfied.
; const printer = ;const mobile = ; const MyComp = Styled;
Of corse, the Emotive's Query
object is re-exported too. Use it to compose your media queries:
; const printer = ;const tablet = ; const MyComp = Styled;
Nesting
Yes, you can use nested media query wrappers, together with props based properties, with no limits.
const MyComp = Styled;