Skip to content

Latest commit

 

History

History
41 lines (29 loc) · 846 Bytes

useStyles.md

File metadata and controls

41 lines (29 loc) · 846 Bytes

useStyles() Addon

useStyles() interface provides a style map as a second argument to your component, next to props.

const cssMap = {
    main: {
        border: '1px solid red'
    }
};

const MyComp = useStyles(cssMap, (props, styles) => {
    return <div className={styles.main} />
});

You can specify the name our your component as a third argument.

useStyles(cssMap, MyComp, 'MyComponent');

Or you can name your function, in that case the function name will be automatically picked up.

const MyComp = useStyles(cssMap, function MyComponent (props, styles) {
    return <div className={styles.main} />
});

Installation

Install useStyles addon and its dependencies:

Read more about the Addon Installation.