Skip to content

Nested theme color DEFAULT key is silently dropped — bg-brand generates nothing #17

Description

@glennmichael123

Summary

When a theme color is defined as a nested object with a DEFAULT key (the Tailwind convention), the DEFAULT variant never generates a rule. Numbered/named sub-keys work fine, and flat string keys work fine — only DEFAULT is dropped, silently.

Version: @cwcss/crosswind 0.2.4, Bun 1.3.13, macOS arm64

Reproduction

import { CSSGenerator, defaultConfig } from '@cwcss/crosswind'

const gen = new CSSGenerator({
  ...defaultConfig,
  theme: {
    ...defaultConfig.theme,
    extend: {
      colors: {
        brand: { DEFAULT: 'var(--brand)', 2: 'var(--brand-2)' },
      },
    },
  },
})
gen.generateBatch(['bg-brand', 'text-brand', 'bg-brand-2'])
console.log(gen.toCSS(false, false))

Actual output

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

bg-brand and text-brand produce nothing — no rule, no warning.

Expected output

.bg-brand {
  background-color: var(--brand);
}
.text-brand {
  color: var(--brand);
}
.bg-brand-2 {
  background-color: var(--brand-2);
}

Workaround

Flatten the palette to string keys — these all generate correctly:

colors: {
  'brand': 'var(--brand)',
  'brand-2': 'var(--brand-2)',
}

Notes

  • Affects every utility prefix tried (bg-, text-, border-), and hover/focus variants of the DEFAULT form are likewise missing.
  • The same shape works in Tailwind, where brand: { DEFAULT: ... } makes bg-brand resolve to the DEFAULT value, so configs ported from Tailwind break silently — in our app this surfaced as a login page with a white background and an invisible submit button, since bg-bg, text-text, and bg-accent were all DEFAULT variants.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions