For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /examples/css-modules.md.

CSS Modules

Component styles from a .module.css file, with class names hashed at build time so they can't clash with other styles.

What it shows

  • Importing a .module.css file — import styles from './demo.module.css' gives you an object that maps each class name to its hashed name. See CSS Modules.
  • [class]="styles['card']" — applies a hashed class in the template. The component exposes styles as a field so the template can read it.
  • A type declaration — src/css-modules.d.ts declares *.module.css imports, so TypeScript accepts them.
  • The hashed names on screen — the last card prints what card and title compile to.