Lesson 42 of 50
cssCSS Modules (Scoped CSS)
8 mins
Course progress84%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 42 of 50
css8 mins
Keep these ideas in mind as you work through the lesson.
CSS Modules generate unique class names at build time, preventing global leaks.
import styles from './Button.module.css';
<button className={styles.primary}>Click</button>
Resulting HTML:
<button class="Button_primary__3X1yZ">Click</button>
Works with React, Vue, Svelte, and webpack.