Skip to content

Latest commit

 

History

History
60 lines (42 loc) · 1 KB

hyperstyle.md

File metadata and controls

60 lines (42 loc) · 1 KB

hyperstyle() Addon

The hyperstyle() creates a new hyperscript function h that you use to create your virtual DOM elements.

const h = nano.hyperstyle({
    foo: {
        color: 'red'
    }
});

const App = () =>
    h('div', {styleName: 'foo'}, 'My app...');

Then in your elements you use styleName prop to pick one of the defined styles.

For TypeScript you can set in tsconfig.json to use h as hyperscript function.

{
    "compilerOptions": {
        "jsxFactory": "h"
    }
}

For Babel you can use jsx pragma to set h as hyperscript function.

/** @jsx h */

This way you can use JSX in your code:

/** @jsx h */

const h = nano.hyperstyle({
    foo: {
        color: 'red'
    }
});

const App = () =>
    <div styleName="foo">My app..</div>;

Installation

Simply install hyperstyle addon and its dependencies:

Read more about the Addon Installation.