Sass configuration

Build-time customization with @use "config": pick the modules, set the breakpoints, scale the typography, rebrand the prefix.

Description

The compiled CSS covers everything, but the source is modular Sass. The two shipped entry points are forma-css.scss (everything) and forma-css-core.scss (a commented example of a trimmed build). To customize the build, write your own entry that configures config with @use "config" with (...) and then loads index. Everything you pass in with () overrides the !default values of _config.scss.

@use "config" with (
  $css-var-prefix: --mybrand-,
  $modules: (
    "content/typography": true,
    "content/buttons": true,
    "components/card": true,
    "components/modal": true,
    "forms/basics": true,
    "components/nav": false,
    "components/toast": false
  )
);
@use "index";

You ship exactly the CSS you use: a landing page with typography, buttons, cards and modals compiles to a fraction of the full build, which keeps the eco budget low. The module map is also the checklist of what forma-css contains.

Keep your entry file next to the package and compile it with the Sass module system already in use (Dart Sass). Pair a trimmed build with runtime custom properties: modules decide what exists, custom properties decide how it looks.

What a trimmed build still styles

A trimmed build keeps the always-on base: typography, plus exactly the modules you enable in $modules. Everything else is your choice.

Typography is always on

Headings and paragraphs come from $text-sizes, the module map only trims components, forms and content extras.

Card module

Enable or disable any component with a single line in $modules.

HTML
<h2>Typography is always on</h2>
<p>Headings and paragraphs come from $text-sizes, the module map only trims components, forms and content extras.</p>
<article class="card">
  <h3>Card module</h3>
  <p>Enable or disable any component with a single line in $modules.</p>
</article>
<button>Buttons module</button>

$modules

The map that decides what gets compiled. A module set to false is simply not emitted: no dead CSS, no overrides to fight. layout/normalize and layout/layout always compile; typography is part of the base too – everything else is optional.

ModuleCompiles
"content/typography": trueText sizes, headings, paragraphs
"content/buttons": trueButtons
"content/badge": trueBadges
"content/figure": trueFigures and captions
"content/icons": trueInline icon sizing (.bi)
"content/mark": trueHighlighted marks
"content/table": trueTables
"content/blockquote": trueBlockquotes
"content/code": trueInline and block code
"components/nav": trueNavigation bar
"components/accordion": trueAccordions
"components/tab-nav": trueTab navigation
"components/dropdown": trueDropdowns
"components/burger-menu": trueBurger menu
"components/toast": trueToasts
"components/off-canvas": trueOff-canvas panels
"components/modal": trueModals
"components/card": trueCards
"components/tooltip": trueTooltips
"forms/basics": trueLabels, inputs, selects, textareas
"forms/radio-checkbox": trueCheckboxes and radios
"forms/switch": trueSwitches
"forms/hidden-search": trueHidden search
"forms/validation": truearia-invalid validation states
"layout/helpers": trueUtility classes (.sm, .lg, .text-*)

$breakpoints

Each key carries a breakpoint (media query), a viewport (max content width) and a root-font-size multiplier that scales typography up with the screen.

KeyBreakpointViewportRoot font sizeTypical use
sm600px540px×1.1Mobile styles, hyphens on headings
md768px720px×1.1Tablet layout shifts
lg1024px960px×1Desktop layout, hidden search at 30vw
xl1450px1200px×1.1Wide desktop
xxl1536px1400px×1.2Ultrawide

$text-sizes

The typography scale, selector by selector. Each entry can set size, line-height, letter-spacing, margin, font-family, font-weight and mobile-hypens; variable-name also emits runtime custom properties (--forma-heading1-font-size and so on), so every build-time value stays overridable at runtime.

$text-sizes: (
  "h1, .heading-1": (
    variable-name: heading1,
    size: 4em,
    line-height: 95%,
    margin: 0.75em 0 0.5em,
    font-family: $font-family-headings,
    font-weight: 400
  )
);

$css-var-prefix

Rebrand the token prefix, e.g. --mybrand-, and every generated custom property follows. Colors, icons and all other SCSS variables in _config.scss are compiled to runtime var() references, so they are customized with custom properties, not with with ().