react-style-comp
Locally scoped CSS for React components
Following "Make everything a component", turn your CSS into a component and gain the advantages of a familiar syntax with componentized style reuse.
- Inline CSS syntax
- Locally scoped styles with element nesting supported
- Dynamic CSS properties with ES6 template literals
- Package styles as a component for reuse
- No build tool or pre-processor needed
Usage
;; { return <div> <Style>` { border: 2px solid blue; } p { color: red; background-color: ; } `</Style> <p>Hello World!</p> </div> ;}
Install
npm install react-style-comp --save
How does it work?
Each Style
component outputs an HTML style
element with the CSS selectors prefixed with a unique class name. This class name is also added to the parent element of the Style
component.
The usage example above, might produce the following DOM output.
style> .uid-H1MaV06lZ { border: 2px solid blue; } .uid-H1MaV06lZ p { color: red; background-color: inhert; } Hello World!
Test
npm installnpm test