Skip to content
Advertisement

i have “react-scripts”: “^4.0.3”, installed but still i’m not able to use Css Modules

    **This is my Styles.css File**
   .headingStyle
    {font-size:4rem;
    color:blue;}

Iam importing these styles here but nothing is being applied to the heading

import React from "react"
import styles from "./Css/styles.css"

function App()
{
  return (
<div>
    <h1 class={styles.headingStyle}> CSS3 Testimonials Slider</ h1>

</div>
  )
}
export default App

Advertisement

Answer

According to create-react-app documentation on CSS modules you should name your file styles.module.css and then import it like you already did

import styles from './styles.module.css';
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement