Configuration and scripts for Create React App - With CSS Modules
npm install react-scripts-cssmodulesAdds CSS Modules to Create React App.
create-react-app my-app --scripts-version react-scripts-cssmodulesreact-scripts and install react-scripts-cssmodules.import mystyles.css[name].module.css and the use as normal css modules.``css`
.button {
padding: 20px;
}
`css`
.button {
color: green;
}
`js
import React, { Component } from 'react';
import './another-stylesheet.css'; // Import regular stylesheet
import styles from './Button.module.css'; // Import css modules stylesheet as styles
class Button extends Component {
render() {
// You can use them as regular CSS styles
return
$3
No clashes from other .button classnames`html
``Any additional numbers are fixes for this app only. E.g. v1.1.51 is v1.1.5 of React App with a fix only for cssmodules.
See this CRA Issue for more details, or for a more indepth guide check out this article.