Skip to content

Configuration

Theme customization

Add, change and remove tokens.

Add and change

Tokens merge over the defaults, one at a time.

ts
import { defineConfig } from "@croff/core";

export default defineConfig({
  theme: {
    colors: {
      accent: "#ff5c00",
      brand: "#8b5cf6",
    },
  },
});

accent is new, brand changes, and everything else stays.

Remove

null removes a token or a whole group.

ts
import { defineConfig } from "@croff/core";

export default defineConfig({
  theme: {
    colors: { red: null, gray: null },
    shadows: null,
  },
});

Now bg(red) is an error, which is how you enforce a smaller palette.

Mistakes that are rejected

These mistakes stop the build, with a message saying what to change:

MistakeExampleCode
A scale that isn't an objectcolors: "red"invalid-scale-value
A token named after a keywordspacing: { full: "1px" } replaces width(full)reserved-token
A breakpoint named after a state variantbreakpoints: { hover: "500px" }reserved-token
A breakpoint name that can't be a variantbreakpoints: { Tablet: "500px" }invalid-token-name
One token written twice in the same theme{ "a-b": "red", a: { b: "blue" } }token-collision
Two scales that produce one custom propertytextSize and textSizestoken-collision

Replacing a token from an earlier layer is fine, however it's written. That's how overrides work.

Start from nothing

ts
import { defineConfig } from "@croff/core";

export default defineConfig({
  preset: "none",
  theme: {
    colors: { ink: "#111111", paper: "#fafafa" },
    spacing: { 1: "4px", 2: "8px" },
  },
});

With an empty preset, responsive variants exist only for the breakpoints you define.

Precedence

From lowest to highest: the preset, then plugin themes in order, then your theme.

Custom scales

Any other key defines a new scale, which custom utilities can read. See Extending the theme.

Validation

ScaleMust be
colorsA hex color, a color function or a named color.
spacing, radius, textSizesA length, 0 or a CSS function.
letterSpacingsA length, a CSS function or normal.
lineHeightsA number, a length or normal.
textWeightsA number, normal or bold.
breakpointsA width in px, em or rem.
durationsA time such as 200ms.
Other scalesAny value that can't break out of a declaration.

Token names can contain letters, digits, - and _.