Classy logo

npm version npm downloads build status dependency status devdependency status


### Table of Contents - [Install](#install) - [Getting Started](#getting-started) - [Usage](#usage) - [API](#api) Install ------- ##### `npm install react-classy` Getting Started --------------- Classy makes styling React components *composable*, *extensible*, and *simple*. Implementation requires only 3 steps: 0. Import `react-classy` into your React component module 0. Decorate your React component class with `@Classy`. 0. Assign a CSS string to a static `style` prop on your React component class. The styles defined on your React component will get automatically injected into the DOM right before your component mounts. Check out some examples of basic and advanced usage in the next section. Usage ----- ### Basic ```js import React, { Component } from 'react'; // Import Classy import Classy from 'react-classy'; // Decorate your component @Classy export default class Button extends Component { // Add your CSS styles static style = ` .button { background: blue; } ` render() { return ( ); } } ``` ### Advanced Classy is also highly customizable and supports asynchronous style rendering, custom middleware, and theming! In the next example, we'll demonstrate all of the aforementioned while creating a button that switches themes when clicked. ```js import React, { Component } from 'react'; // Import the decorator and utils modules import Classy, { Utils } from 'react-classy'; // CSS pre-processor import stylus from 'stylus'; @Classy({ // Makes Classy play nice with react-hot-loader :) hot: true, // Logs component css to console debug: true, // Will access specified prop to load component styles // instead of default `style` prop styleProp: 'stylus' }) export default class ToggleButton extends Component { render() { return