Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] animation fails when transitioning between oklch and hex color formats #3058

Open
davbrito opened this issue Feb 11, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@davbrito
Copy link

Description:

I'm experiencing an issue when trying to animate the backgroundColor, specifically when animating between colors defined in different formats: oklch and #hex. The animation fails, and I receive a console warning when transitioning.

Example Snippet:

    <motion.div
      animate={{
        backgroundColor: isActive ? "oklch(0.65 0.18 260)" : "#ffffff",
      }}
    />

Console Warning:

'oklch(0.65 0.18 260)' is not an animatable color. Use the equivalent color code instead.

CodeSandbox:

https://codesandbox.io/p/devbox/small-http-j8rxt3

Steps to reproduce

Steps to reproduce the behavior:

  1. Go to the CodeSandbox
  2. Click on 'Toggle color'
  3. Observe that the background color animation fails, and the console warning appears.

Expected behavior

The backgroundColor should smoothly animate between the oklch color and the hex color.

In my real use case, the oklch color comes from a CSS variable defined by Tailwindcss V4.

Environment details

motion version: [email protected]
Browser: Google Chrome 133.0.6943.53

@davbrito davbrito added the bug Something isn't working label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant