riot-jss
JSS plugin for RiotJS.
JSS is css-in-js. It allows you to write styles in javascript object syntax.
Installation
npm i -S riot-jss
Usage
This plugin provides following functionality in a component scope:
- Object
classes
- a map of original class names to compiled css classes. - Method
jss({ className: true})
- switches classes based on a condition. - Method
setStyles({...styles})
- set new styles and update component
Global plugin initialization
Install the plugin globbaly:
//
Local plugin initialization
Decorate component's exports:
Black Background
Writing styles
In order to make the JSS work in scope of a riot component, just add a property called styles
into your component exports.
Property styles
must be a valid JSS object.
styles ...
An example
Black background class white text class
styles state: ...
my-compoent.jss
myClass: background: 'black' text: color: 'white'
Licence
MIT