question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default CSS not loaded when using CSS modules

See original GitHub issue
screen shot 2018-08-07 at 10 50 25 am

Hi, 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:closed
  • Created 5 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
harry100commented, Dec 26, 2018

Use both style-loader and css-loader in the config.

{
            test: /\.css$/,
            use: [
              { loader: "style-loader" },
              { loader: "css-loader" },
        ]
}

This solved the issue for me

2reactions
gman666commented, Nov 5, 2018

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…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found