framework7io/framework7 · error · Error

`primaryDim` color is undefined prior to 2025 spec.

Error message

`primaryDim` color is undefined prior to 2025 spec.

What it means

The DynamicScheme getter primaryDim exists only for the 2025 (expressive) spec; for earlier spec versions the underlying colors.primaryDim() returns undefined. The getter throws instead of returning a wrong color, telling the caller this role is not available prior to the 2025 spec.

Source

Thrown at src/core/shared/material-color-utils.js:2265

  }
  get outlineVariant() {
    return this.getArgb(this.colors.outlineVariant());
  }
  get shadow() {
    return this.getArgb(this.colors.shadow());
  }
  get scrim() {
    return this.getArgb(this.colors.scrim());
  }
  get surfaceTint() {
    return this.getArgb(this.colors.surfaceTint());
  }
  get primary() {
    return this.getArgb(this.colors.primary());
  }
  get primaryDim() {
    const primaryDim = this.colors.primaryDim();
    if (void 0 === primaryDim) throw new Error("`primaryDim` color is undefined prior to 2025 spec.");
    return this.getArgb(primaryDim);
  }
  get onPrimary() {
    return this.getArgb(this.colors.onPrimary());
  }
  get primaryContainer() {
    return this.getArgb(this.colors.primaryContainer());
  }
  get onPrimaryContainer() {
    return this.getArgb(this.colors.onPrimaryContainer());
  }
  get primaryFixed() {
    return this.getArgb(this.colors.primaryFixed());
  }
  get primaryFixedDim() {
    return this.getArgb(this.colors.primaryFixedDim());
  }
  get onPrimaryFixed() {

View on GitHub (pinned to 6557591266)

Solutions

  1. Create the scheme with specVersion set to 2025 (e.g. pass SpecVersion.SPEC_2025 / use the 2025 constructor) before reading primaryDim.
  2. Guard the access with a specVersion check and fall back to a computed dim tone for older specs.
  3. If the dim variant is not needed, use scheme.primary instead.

Example fix

// before
const scheme = new DynamicScheme(...); // specVersion 2021
const c = scheme.primaryDim;
// after
const scheme = new DynamicScheme({ ..., specVersion: SpecVersion.SPEC_2025 });
const c = scheme.primaryDim;
Defensive patterns

Strategy: type-guard

Validate before calling

function canReadDim(scheme) {
  return scheme.specVersion != null && String(scheme.specVersion).includes('2025');
}
const c = canReadDim(scheme) ? scheme.primaryDim : null;

Type guard

function supports2025Roles(scheme) {
  return scheme && scheme.specVersion === '2025';
}

Try / catch

try {
  argb = scheme.primaryDim;
} catch (err) {
  if (err.message.includes('`primaryDim` color is undefined')) {
    argb = scheme.primary; // fallback for pre-2025 specs
  } else throw err;
}

Prevention

When it happens

Trigger: Accessing scheme.primaryDim on a DynamicScheme constructed with specVersion 2021 (default) or otherwise without 2025 support, where colors.primaryDim() evaluates to undefined.

Common situations: Code written against the 2025 spec run with a scheme built via a constructor defaulting to specVersion 2021; upgrading material-color-utils and referencing new dim roles while still creating legacy schemes.

Related errors


AI-assisted analysis of framework7io/framework7@6557591266 (2026-09-02). Data as JSON: /api/errors/ab0f784e845eb57a. Report an issue: GitHub.