The design system favors clarity over succinctness. This means the design system may be verbose, but it should deliver clarity, predictability, and legibility in exchange.
CSS class naming convention
To avoid conflicting with other libraries and existing code, the design system namespaces its CSS class names with
Prefixes are added to class names to make it more apparent what job the class is doing.
|Indicates layout-related styles. Example: |
|Indicates a component. Example: |
|Indicates a utility. Example: |
These prefixes can sometimes be followed by a "breakpoint prefix". Learn more about breakpoint prefixes.
Following the namespace and prefix is a name conforming to BEM syntax.
Put all together, a CSS class can be broken down to these key parts:
- Block is a standalone entity that is meaningful on its own. For example:
- Element is a part of a block that has no standalone meaning and is semantically tied to its block, such as
- Modifier is a flag on a block or element and is used to change appearance or behavior. For example:
BEM’s strict naming rules can be found here.
The CSS naming convention outlined here was heavily influenced by:
- CSS Architecture for Design Systems, by Brad Frost
- Thoughtful CSS Architecture, by Nathan Rambeck
- More Transparent UI Code with Namespaces, by Harry Roberts