html2canvas icon indicating copy to clipboard operation
html2canvas copied to clipboard

Add support for oklch

Open nicastelo opened this issue 8 months ago • 2 comments

Summary

This PR fixes a color parsing issue by adding support for the oklch() color function in html2canvas. Tailwind CSS 4 now uses OKLCH for color definitions, and without this change html2canvas was unable to parse these colors correctly.

  • Bug: Fix color parsing for oklch() values
  • Feature: Add support for the oklch() color function

Motivation

Tailwind CSS 4 uses OKLCH to define colors, which led to incorrect rendering of colors when using html2canvas. This change addresses issue #3235 by updating the color.ts file to include an oklch() parser that converts OKLCH values to sRGB. This ensures compatibility and correct color rendering when using Tailwind CSS 4.

Test plan (required)

TODO

nicastelo avatar Mar 13 '25 20:03 nicastelo

Nice! I'm trying to use it, but it's giving the me this error.

Error: Attempting to parse an unsupported color function "oklab"

This gets used when dealing with opacity/transparency in colors, like in tailwind you can use text-red-500/50 and gets compiles to:

.text-red-500\/50 {
  color: color-mix(in oklab, var(--color-red-500) 50%, transparent);
}

n2k3 avatar Mar 23 '25 09:03 n2k3

some update?

Luisgustavom1 avatar Sep 16 '25 19:09 Luisgustavom1