Card module
Enable or disable any component with a single line in $modules.
Build-time customization with @use "config": pick the modules, set the breakpoints, scale the typography, rebrand the prefix.
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.
A trimmed build keeps the always-on base: typography, plus exactly the modules you enable in $modules. Everything else is your choice.
Headings and paragraphs come from $text-sizes, the module map only trims components, forms and content extras.
Enable or disable any component with a single line in $modules.
<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>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.
| Module | Compiles |
|---|---|
"content/typography": true | Text sizes, headings, paragraphs |
"content/buttons": true | Buttons |
"content/badge": true | Badges |
"content/figure": true | Figures and captions |
"content/icons": true | Inline icon sizing (.bi) |
"content/mark": true | Highlighted marks |
"content/table": true | Tables |
"content/blockquote": true | Blockquotes |
"content/code": true | Inline and block code |
"components/nav": true | Navigation bar |
"components/accordion": true | Accordions |
"components/tab-nav": true | Tab navigation |
"components/dropdown": true | Dropdowns |
"components/burger-menu": true | Burger menu |
"components/toast": true | Toasts |
"components/off-canvas": true | Off-canvas panels |
"components/modal": true | Modals |
"components/card": true | Cards |
"components/tooltip": true | Tooltips |
"forms/basics": true | Labels, inputs, selects, textareas |
"forms/radio-checkbox": true | Checkboxes and radios |
"forms/switch": true | Switches |
"forms/hidden-search": true | Hidden search |
"forms/validation": true | aria-invalid validation states |
"layout/helpers": true | Utility classes (.sm, .lg, .text-*) |
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.
| Key | Breakpoint | Viewport | Root font size | Typical use |
|---|---|---|---|---|
sm | 600px | 540px | ×1.1 | Mobile styles, hyphens on headings |
md | 768px | 720px | ×1.1 | Tablet layout shifts |
lg | 1024px | 960px | ×1 | Desktop layout, hidden search at 30vw |
xl | 1450px | 1200px | ×1.1 | Wide desktop |
xxl | 1536px | 1400px | ×1.2 | Ultrawide |
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
)
);
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 ().