Skip to content

oklch color definitions don't work with color/opacity syntax — classes missing or incomplete #14499

@andronocean

Description

@andronocean

What version of Tailwind CSS are you using?

v3.4.13

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

Tested with Bud.js 6.23.3 (using postcss 8.4.24) and Tailwind Playground.

What version of Node.js are you using?

v20.16.0

What browser are you using?

N/A

What operating system are you using?

macOS Sonoma 14.7

Reproduction URL
https://play.tailwindcss.com/dDmsole8X3

Describe your issue

When colors are added to a Tailwind config using the standard oklch() function, the resulting color classes do not work with Tailwind's methods of controlling opacity. For a color like primary: "oklch(68% 0.15 237.33)", these two issues appear:

  1. The simple color classes generated are missing the opacity properties like var(--tw-bg-opacity) and var(--tw-text-opacity) — it seems that Tailwind just copies the value directly.
  2. Tailwind completely fails to generate modified-opacity classes for these colors, like bg-primary/50.

The same problems occur if I explicitly declare an opacity in the color definition: primary: "oklch(68% 0.15 237.33 / 1)".

Classes ARE generated correctly if I use the <alpha-value> placeholder in color definitions: primary: "oklch(68% 0.15 237.33 / <alpha-value>)". However, this magic is not explained anywhere in Tailwind's color documentation: https://tailwindcss.com/docs/customizing-colors

The playground link shows both issues and contrasts the correct behavior of colors defined using rgb(r g b / a) notation.

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