An open API service indexing awesome lists of open source software.

https://github.com/jschr/react-style-side-effect

React components to style html, body and root app elements.
https://github.com/jschr/react-style-side-effect

Last synced: about 2 months ago
JSON representation

React components to style html, body and root app elements.

Awesome Lists containing this project

README

          

React Style Side Effect
=========================

[![npm](https://img.shields.io/npm/v/react-style-side-effect.svg?style=flat-square)](https://www.npmjs.com/package/react-style-side-effect)

Declaritvely style elements that exist outside of the React tree. Works great with css-in-js libraries such as:
- [aphrodite](https://github.com/Khan/aphrodite)

## Installation

```
npm install --save react-style-side-effect
```

## Basic Usage

```js
import React from 'react'
import createStyleSideEffect from 'react-style-side-effect'

const HtmlStyle = createStyleSideEffect(document.docElement)
const BodyStyle = createStyleSideEffect(document.body)
const RootStyle = createStyleSideEffect(document.getElementById('root'))

export default function MyApp() {
return (



...



)
}
```

## Usage with Aphrodite

```js
import React from 'react'
import { StyleSheet, css } from 'aphrodite'
import createStyleSideEffect from 'react-style-side-effect'

const HtmlStyle = createStyleSideEffect(document.docElement)

const styles = StyleSheet.create({
html: {
fontSize: '14px' // base font size for rem units
}
})

export default function MyApp() {
return (

...

)
}
```