Naming Convention - Custom Properties #7577
Locked
oliverschuerch
announced in
Architecture Decisions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Context
CSS custom properties (CSS variables) inherit through the entire DOM tree — including into shadow DOM. This means a generic variable like
--max-widthset anywhere on a page will silently propagate into every web component's shadow root. In multi-vendor environments where applications combine components from different libraries, unscoped variable names are virtually guaranteed to collide, causing hard-to-debug visual regressions.Decision
All CSS custom properties in Swiss Post web components (HTML/CSS and WebComponents) must follow the naming pattern:
--post— company prefix, attributes the variable to the Swiss Post Design System and prevents cross-vendor collisions.<component>— component name (e.g.tooltip,footer), prevents collisions between components within the system.<property>— descriptive name of the value being controlled.Shared design tokens that are intentionally global use only the company prefix (e.g.
--post-current-fg).Consequences
--post-tooltip-max-widthto affect the tooltip.--post-<component>.Example
All reactions