Default CSS not loaded when using CSS modules
See original GitHub issueHi, I just wanted to ask if I’m doing it right. Whenever I add the Calendar component in my react project the default styling is not being applied.
I’m using it like this. Can you advise what I’m doing wrong? Thank you!
import React from 'react';
import Calendar from 'react-calendar';
import classes from './Filter.css';
const filter = (props) => (
<div className={classes.Filter}>
<Calendar />
</div>
);
Note: I also ejected my CRA and enabled CSS modules
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Webpack css-loader doesn't load css when the modules ...
in order to override css class you need to use plain css, eg. import './styles.css'; class App extends React.Component { ...
Read more >Using CSS Module Scripts to import stylesheets - web.dev
With the new CSS module scripts feature, you can load CSS style sheets with import statements, just like JavaScript modules.
Read more >Solving the React Error: Not Picking Up CSS Style | Pluralsight
Unsaved Files in the Source Folder. Inside the react-app folder, some folders are saved by default, such as node-module, public, and source.
Read more >How to configure CSS and CSS modules in webpack
"A CSS Module is a CSS file in which all class names and animation names are scoped locally by default." CSS is global...
Read more >Using CSS Modules in React - OpenReplay Blog
A very good point is that it is not necessary to configure WebPack: React handles everything for you when you install create-React-app; thus, ......
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
Use both style-loader and css-loader in the config.
This solved the issue for me
I suggest copying the stylesheet from dist/Calendar.css into your own project, and then customising from there.
As you appear to be using css-loader, with modules: true, everything is local scope by default. To style child selectors, you will then need to export them as global, e.g. with sass:
.reactCalendar :global { … paste all the Calendar.css styles here }
You can then include it in your jsx with:
<Calendar className={style.reactCalendar} value={new Date()} />
Working well for me…