Skip to content

Configuration

CSS variables

How tokens reach the browser.

Tokens compile to custom properties on :root.

html
<div class="bg(brand) padding(4)"></div>
Generated CSS
:root {
  --croff-color-brand: #c8fd12;
  --croff-spacing-4: 1rem;
}

.padding\(4\) {
  padding: var(--croff-spacing-4);
}

.bg\(brand\) {
  background-color: var(--croff-color-brand);
}

Naming

--croff-<scale>-<token>, with these scale prefixes:

ScalePrefix
colorscolor
spacingspacing
radiusradius
fontsfont
textSizestext-size
textWeightstext-weight
lineHeightsline-height
letterSpacingsletter-spacing
shadowsshadow
durationsduration

Custom scales use their name in kebab case.

Which variables are emitted

The variables option controls this.

ValueEmits
"used"Only tokens used by compiled rules. This is the default.
"all"Every token, for referring to them from your own CSS.
"none"None, for when you provide them yourself.

Overriding at runtime

Custom properties cascade, so tokens can change by scope without rebuilding:

css
@media (prefers-color-scheme: light) {
  :root {
    --croff-color-dark: #ffffff;
  }
}

.campaign {
  --croff-color-brand: #ff5c00;
}