Skip to content

rtsao/react-stylematic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-stylematic

build status dependencies status npm version

A stylematic wrapper for React

Quick example

/** @jsx createElement */

const createElement = require('react-stylematic'); 

const App = () => (
  <div style={{
    color: 'red',
    background: 'linear-gradient(#fff, #eee)',
    ':hover': {
      color: ['rgba(0,75,255,0.8)', 'blue']
    }
  }}>
    Hello World!
  </div>
);

Rendered HTML

<div class="_style_4e1hWd" style="color: red">Hello World!</div>

Automatically injected CSS into document <head>

<style data-styletron>
._style_4e1hWd {
  background: -webkit-linear-gradient(#fff, #eee) !important;
  background: -moz-linear-gradient(#fff, #eee) !important;
  background: linear-gradient(#fff, #eee) !important
}
._style_4e1hWd:hover {
  color: blue !important;
  color: rgba(0,75,255,0.8) !important
}
</style>

Extraction of CSS on server

const React = require('react');
const ReactDOM = require('react-dom/server');
const {renderStatic} = require('styletron-server');

const App = require('./app');

const {html, css, hydrationSrc} = renderStatic(() => {
  return ReactDOM.renderToString(<App/>);
});

About

A stylematic wrapper for React

Resources

License

Stars

Watchers

Forks

Packages

No packages published