CSS Modules

You create a ".module.css" file in the same folder as your component.
This uses className but the CSS is scoped to the component.
React will generate a specific unique class for each rendered component and assign the CSS to that class.


.button { 
   background-color : 'red';


import style from 'button.module.css'  

const Button = () => {
   return <button className = { style.button } >My Button</button>

© 2023 Better Solutions Limited. All Rights Reserved. © 2023 Better Solutions Limited TopPrevNext