react-jss-theme
Theming solution for React based on JSS that follows the ideas of future-react-ui and theme-standard. In fact you can implement the proposed theme-standard spec using this solution.
Installation
npm install react-jss-theme --save
Usage
const themeFactory = const RawButton = <button className= classesbutton data-color= color > <span className= classeslabel > children </span> </button> const Button = RawButton const App = <ThemeContextProvider themeVars= color: "red" > <Button>Hello</Button> </ThemeContextProvider> ReactDOM
With decorator syntax
You can use ES7 with decorators (using babel-plugin-transform-decorators-legacy).
@const Button = <button className= classesbutton data-color= color > <span className= classeslabel > children </span> </button>
Customize component theme
Components wrapped with the withTheme
decorator, accepts a theme
attribute
which merges with the component theme. Class names are never overwritten
but appended to the existing ones.
const customThemeFactory = @const CustomButton = <Button theme= theme > children </Button>
Passing a custom JSS instance
You can pass a custom JSS instance to the ThemeContextProvider
instead of the default one.
const App = <ThemeContextProvider themeVars= myThemeVars jss= myCustomJSS > <Button>Hello</Button> </ThemeContextProvider>
Passing style sheet options
You can pass style sheet options to createThemeFactory
.
For all available options consult the JSS API Documentation.
const themeFactory =