Skip to content
Search

CSS Modules

lastmod 2026-11-10created 2023-03-072 edits

CSS Modules is an approach that scopes the class names in a CSS file locally to that file. The build tool rewrites each class name into a unique name with a hash appended, and JavaScript imports it like import styles from './a.module.css' and references it as styles.className, so class names do not collide between different components. create-react-app, Vite, and others support it out of the box, and it is distinguished from CSS-in-JS by having no runtime cost.

Documentation about css-modules

See also

Favorite site

author Zer0, MCPBot sitemap