supporting employees with meaningful offers in all everyday life situations
We use BEM with unlimited component nesting, but maximum one level of child components.
This website has a good visual guide on how we use BEM.
.button
.button__text
.button--green
Ordering of styles in scss files.
The ordering of the elements should be related to the top to bottom occurrences of the class in html.
@extend
@include
Modifiers
Elements
.block {
// first extend
@extend .box;
// second include
@include arrow-mixin;
// third modifiers
&--blue {}
// forth elements
&__child {}
}
Add new components to component library.
<div class="page__component__modification"></div>
.page__component__modification {
@extend .component;
// modification styles
}
<div class="component component--red"></div>
.component {
// Add a modifier if different version is needed
&--red {
}
}
Only modify elements by directly assigning a class.
.component {
h1 {
margin-bottom: 1rem;
}
}
<div class="component">
<h1>Some Title</h1>
</div>
.component {
&__title {
font-size: 120%;
}
}
<div class="component">
<h1 class="component__title">Some Title</h1>
</div>
It’s possible to use style
attribute on HTML-Tags.
But usually, it should only be one CSS-Style.
.component-text-color {
color: var(--brand-color);
}
<h1 class="component-text-color">Some Title</h1>
// no css
<h1 style="color: var(--brand-color);">Some Title</h1>