1

I am using TailwindCSS v4 with Next.js v15.0.4.

In globals.css I have:

@theme {
  --animate-float: float 4s  inifinite
  --animate-wiggle: wiggle 1s infinite
  

  @keyFrames[ wiggle {
    0% { 
      transform: rotate(-3deg);
    }
    100% {
      transform: rotate(3deg);
    }
  },

  @keyFrames float {
    0%  { 
      transform: translateY(0);
    }
    100% {
      transform: translateY(-10px);
    }
  }]
}

in ShoeDetail.tsx is have:

<Image className="animate-wiggle" src={nike1} width={600} height={500} alt="Picture of shoe"/>

There is only one animation shown in the available list, and the animation does not have any effect.

The built-in animate-pulse works fine.

1
  • This question is similar to: How to use @keyframes in Tailwind CSS version 4?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Apr 12 at 7:31

1 Answer 1

0

Problems

Specifically in your case, the CSS is invalid:

@keyFrames[ wiggle {

And the semicolons are also missing:

--animate-float: float 4s  inifinite
--animate-wiggle: wiggle 1s infinite

And the import of TailwindCSS v4 is missing.

Solution

First, you need to import TailwindCSS v4, and second, CSS is case-sensitive, so it's best to use the original @keyframes instead of @keyFrames; this is what it should look like correctly:

@import "tailwindcss";                  /* added import */

@theme {
  --animate-float: float 4s infinite;   /* added semicolon */
  --animate-wiggle: wiggle 1s infinite; /* added semicolon */

  @keyframes wiggle {                   /* fixed syntax; use @keyframes */
    0% {
      transform: rotate(-3deg);
    }
    100% {
      transform: rotate(3deg);
    }
  }

  @keyframes float {                    /* use @keyframes */
    0% {
      transform: translateY(0);
    }
    100% {
      transform: translateY(-10px);
    }
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.