Guidelines for naming CSS classnames using BEM methodology in React components.
To ensure consistent, predictable, and maintainable CSS classnames across the codebase using CSS Modules. Since CSS Modules automatically scope styles locally, we avoid complex naming conventions like BEM in favor of simple, descriptive camelCase names.
camelCase for class names so they can be accessed via dot notation (e.g., styles.myClass). Do not use kebab-case (e.g., my-class).__ and --) is unnecessary. Use simple, descriptive names (e.g., header, submitButton).camelCase (e.g., myComponent for <MyComponent />), or simply use root.isActive, isDisabled, hasError). Apply them alongside the base class.className prop to the child component.classNames for all conditional classnames: Compose conditional classnames with the classNames utility. Do not use array joins or string interpolation for conditional class logic.className expressions simple and explicit: A className should be either a string literal for static classes or a classNames(...) expression for any dynamic/conditional case.classNames call spans multiple lines (e.g., long arguments or conditional object syntax), assign it to a variable before return to keep JSX readable.import classNames from 'classnames';
import styles from './MyComponent.module.css';
export function MyComponent({ isActive, className }) {
const headerClassName = classNames(styles.header, {
[styles.headerActive]: isActive
});
return (
<div className={classNames(styles.myComponent, className)}>
<div className={headerClassName}>
Header
</div>
</div>
);
}
.myComponent {
/* styles */
}
.header {
/* styles */
}
.headerActive {
/* styles */
}
npx skills add ViewableGravy/css_naming-conventions下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer