Skip to content

invalid-theme-reference

Reports a --theme() reference to a token that is not defined.

This rule reports a --theme() reference in your stylesheet to a token that the theme does not define, when the reference has no fallback. The declaration that contains it produces no CSS.

Reported

.card {
  color: --theme(--color-brand);invalid-theme-reference: `--theme(--color-brand)` names no theme token and has no fallback
}

Fixed

@theme {
  --color-brand: oklch(0.6 0.2 250);
}

.card {
  color: --theme(--color-brand);
}

How to fix

  • Define the token in @theme, as in the example, or correct the spelling of its name.
  • If the token is optional, add a fallback: --theme(--color-brand, blue).

Malformed --theme() syntax causes SW14007 instead.

Rule settings

PresetSeverity
recommendeddeny
strictdeny
stylisticoff

Configure lint to change the severity or options.