Use react CSS modules
See original GitHub issueI assumed create-react-app
uses react-css-modules, but this code does not work (no styles applied):
import React from 'react'
import styles from './styles.css'
const TextField = ({children}) => (
<div className={styles.inputContainer}>
<span className={styles.inputLabel}>{children}</span>
<input className={styles.inputField}/>
</div>
)
export default TextField
It does, however, work when classes are defined as strings rather than scoped to this component. I think it wouldn’t hurt to have this available for projects using create-react-app, what do you think?
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Adding a CSS Modules Stylesheet - Create React App
CSS Modules let you use the same CSS class name in different files without worrying about naming clashes. Learn more about CSS Modules...
Read more >Using CSS modules in React - Bootcamp
A CSS Module is simply a .css file, where classes act similarly to local variables in Javascript. It is a tool that makes...
Read more >Using CSS Modules in React - OpenReplay Blog
In React js, where classes function similarly to local variables in JavaScript, a CSS Module is just a .css file. It lessens React...
Read more >Using CSS Modules In React App - Medium
There are two different ways of using CSS Modules in a React application. When using the Create-React-App tool you are provided with a...
Read more >How to Style React Components Using CSS Modules
How you use CSS modules in React depends on how you create the React application. If you use create-react-app, CSS modules are set...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Create React App does not use or support CSS Modules. You can eject and add them if you’d like.
Great, recent article on using CSS Modules after ejecting Create React App: https://medium.com/nulogy/how-to-use-css-modules-with-create-react-app-9e44bec2b5c2