Skip to content

web-dev-lib/react-css-modules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-css-modules

index.css:

.foo {
    color: #f00;
}

Rainbow.js:

import React from 'react';
import styles from './index.css';
import CSSModules from 'react-css-modules';

class Rainbow extends React.Component {
    render () {
        return <div>
            <span className='foo'>I am rainbow!</span>
            <span className='bar'>I am rainbow!</span>
        </div>;
    }
}

export default CSSModules(Rainbow, styles);

When used, this component will generate:

<div data-reactid=".0">
    <div data-reactid=".0.0">
        <span class="foo index__foo___1fSgh" data-reactid=".0.0.0">I am rainbow!</span>
        <span class="bar" data-reactid=".0.0.1">I am rainbow!</span>
    </div>
</div>

About

Seamless mapping of class names to CSS modules inside of React components.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%