Skip to content

Add support for oklch#3236

Open
nicastelo wants to merge 1 commit intoniklasvh:masterfrom
nicastelo:master
Open

Add support for oklch#3236
nicastelo wants to merge 1 commit intoniklasvh:masterfrom
nicastelo:master

Conversation

@nicastelo
Copy link
Copy Markdown

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

@n2k3
Copy link
Copy Markdown

n2k3 commented Mar 23, 2025

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);
}

@Luisgustavom1
Copy link
Copy Markdown

Luisgustavom1 commented Sep 16, 2025

some update?

@hrishi2814
Copy link
Copy Markdown

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

Getting the same error as well, did you solve it?

@marr
Copy link
Copy Markdown

marr commented Feb 26, 2026

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

Getting the same error as well, did you solve it?

Use "html2canvas-oklch": "^1.5.0-alpha.0",

@hrishi2814
Copy link
Copy Markdown

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

Getting the same error as well, did you solve it?

Use "html2canvas-oklch": "^1.5.0-alpha.0",

For some reason, this still did not work for me, it was giving out the same error, since my usecase was pretty simple as well I just used html-to-image , works well enough!
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants