StableLayout · since 0.1.0
Children sit side by side until the container is narrower than a threshold, then all stack at once.
Pick this part
Build it
- Start with an element and add
class="l-switcher". - Tune
--switcher-thresholdinline if the default (30rem) doesn't fit. - Put the parts inside. The layout sets the space between them, so they need no margins.
Free
Team
Show markup 4 lines
<div class="l-switcher" style="--switcher-threshold: 40rem">
<section class="c-card"><p class="u-margin-0">Free</p></section>
<section class="c-card"><p class="u-margin-0">Team</p></section>
</div>
Check your build
Each piece that doesn't fit was run through mcss-lite validate when this page was built. The output below is real.
Fits
Set the threshold with the custom property.
Free
Team
Show markup 4 lines
<div class="l-switcher" style="--switcher-threshold: 40rem">
<section class="c-card"><p class="u-margin-0">Free</p></section>
<section class="c-card"><p class="u-margin-0">Team</p></section>
</div>
validate: 0 issues
Doesn't fit
Don't invent size modifiers.
<div class="l-switcher l-switcher--wide">
<section class="c-card"><p class="u-margin-0">Free</p></section>
</div>
validate
- error Unknown class "l-switcher--wide". l-switcher has no modifiers. Only classes from the MCSS-Lite contracts exist.
[unknown-class]
Spec sheet
| Property | Default | What it does |
|---|---|---|
--switcher-threshold | 30rem | Container width below which children stack. Set inline, e.g. style="--switcher-threshold: 40rem". |