bem-structure
Overview
This skill guides AI in writing CSS using the BEM (Block Element Modifier) methodology for creating maintainable, scalable, and reusable stylesheets with clear naming conventions and component structure, while exercising judgment about scope, risk, and architectural impact. It also should use BEM in conjunction with Optics, our RoleModel design system, so that it's not recreating things that already exist. If there is already an Optics component that fits the need, it should be used and/or overridden as necessary instead of creating a new BEM block.
The agent should prioritize clarity, predictability, and minimal unintended side effects.
Keywords: CSS review, BEM structure, BEM methodology, CSS best practices, Refactor CSS, Review CSS, Fix my CSS, Fix my BEM, BEM-ify my CSS
What is BEM?
BEM stands for Block Element Modifier - a methodology that helps you create reusable components and code sharing in front-end development.
| Pattern | Syntax | Example |
|---|---|---|
| Block | .block |
.card |
| Element | .block__element |
.card__title |
| Block Modifier | .block--modifier |
.card--elevated |
| Element Modifier | .block__element--modifier |
.card__title--large |
| Multi-word names | .block-name |
.user-profile |