Skip to content

Custom colors not working in CSS #17429

@mirorauhala

Description

@mirorauhala

What version of Tailwind CSS are you using?

v4.0.17

What build tool (or framework if it abstracts the build tool) are you using?

Vite 6.2.0

What version of Node.js are you using?

v22.13.1

What browser are you using?

Chrome

What operating system are you using?

macOS

https://github.com/mirorauhala/tw-custom-properties

Issue

Referencing colors as --color-* properties from a CSS module file does not work unless the color utility is mentioned elsewhere.

For example, if you define a color such as --color-red-custom-1: red and use it from a CSS module file, like this:

.red { background: var(--color-red-custom-1); }

The final build will not contain the custom property defined and the color won't show correctly unless bg-red-custom-1 is used elsewhere, which will cause the property to be included in the build.

Expected

The colors to work. The docs outline the following:

Colors are exposed as CSS variables in the --color-* namespace, so you can reference them in CSS with variables like --color-blue-500 and --color-pink-700:

https://tailwindcss.com/docs/colors#referencing-in-css

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions