๐ Add styleName for React projects using css modules
See original GitHub issueThis is a ๐ feature request.
It will be really nice to have styleName
feature working out-of-the-box or with minimal configuration for React projects like it is done in babel-plugin-react-css-modules which is not working with Parcel.
๐ค Expected Behavior
Code like this should work fine too:
import './App.css'
const App = () => {
return (
<div styleName="app">
Hello World!
</div>
)
}
๐ฏ Current Behavior
Only this one is working:
import styles from './App.css'
const App = () => {
return (
<div className={styles.app}>
Hello World!
</div>
)
}
It will be a bit nicer: save typing and more React-ish.
๐ Possible Solution
Iโm not sure here, but I think it can be done same way as in babel-plugin-react-css-modules
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
How to Style React Components Using CSS Modules
CSS modules provide a way to locally scope CSS class names. You don't have to worry about overriding styles when you use the...
Read more >How to Style Your React App โ 5 Ways to Write CSS in 2021
There is no #1 way to approach to writing styles in React for every project. Every project is different and has different needs....
Read more >Adding a CSS Modules Stylesheet - Create React App
This project supports CSS Modules alongside regular stylesheets using the [name].module.css file naming convention. CSS Modules allows theย ...
Read more >Using CSS modules in React - Bootcamp
If you are using create-react-app , making CSS Module for a component is ... import the css modules stylesheet as styles or [name]Styles...
Read more >Using CSS Modules In React App - Medium
What I just showed you is how you will typically add styles to HTML elements. The browser is able to understand this two...
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 Free
Top 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
I was able to fix this by setting both .babelrc and .postcssrc to use the same generateScopeName:
Can this work using typescript?