css-modules

Generate locally scoped CSS class names for React and Next.js components.

Updated Apr 12, 2026
One-click install
npx skills add https://github.com/gil00pita/lanify --skill css-modules-gil00pita
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: css-modules
Source: https://github.com/gil00pita/lanify/tree/main/.agents/skills/css-modules
Command: npx skills add https://github.com/gil00pita/lanify --skill css-modules-gil00pita

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

CSS Modules provide locally scoped CSS by generating unique class names and enabling safe composition, preventing global name collisions and aiding maintainable styling in component-based apps.

Core Features & Use Cases

  • Locally scoped class names and automatic mapping from CSS to JavaScript imports for frameworks like React, Next.js, and Vite.
  • Support for composition using composes to share styles across modules and create design tokens.
  • TypeScript integration via declaration files or typed-css-modules for safer imports and IDE support.

Quick Start

Create a module CSS file named Button.module.css, import it into your component, and apply the generated class names from the imported styles object.

Frequently Asked Questions about css-modules

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent CSS style leakage in React components?

CSS Modules prevent style leakage by generating locally scoped class names and mapping CSS to JavaScript imports. This mechanism avoids global name collisions and ensures styles remain isolated within component-based UIs.

How do I share styles across multiple CSS Modules?

You can share styles across CSS Modules using the composes rule to combine local classes and create design tokens. This enables safe composition and reusability without introducing global style conflicts.

How do I set up TypeScript integration for CSS Module imports?

TypeScript integration for CSS Modules requires declaration files or typed-css-modules tooling. This setup provides safer imports and enables IDE autocomplete support for generated class name objects.

Can I use CSS Modules with Next.js and Vite?

CSS Modules work with Next.js, Vite, and React by automatically mapping imported module files to scoped class names. Frameworks handle the configuration and compilation to prevent style leakage natively.

How do I handle global vs local scope in CSS Modules?

CSS Modules handle global and local scope by generating unique class names for local styles while allowing explicit global scope declarations. This prevents accidental style overrides and maintains component encapsulation.

What is the best way to structure component-scoped styles?

The best way to structure component-scoped styles is using CSS Modules to map CSS files directly to JavaScript imports. This approach supports composition and ensures maintainable styling in component-based applications.