Skip to content

[v4] Unused keyframes are included in generated CSS #15956

@heidkaemper

Description

@heidkaemper

What version of Tailwind CSS are you using?

v4.0.0

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

Tailwind CLI

What version of Node.js are you using?

v21.6.1

What operating system are you using?

Linux / macOS

Reproduction URL

Check out this repo:
https://github.com/heidkaemper/tailwind4-keyframes-issue

Run the Tailwind CLI with npm run dev

Describe your issue

I've added a custom animation just as described in the docs:
https://tailwindcss.com/docs/theme#defining-animation-keyframes

But although the animation is not used at all, the CSS property and keyframes are included in the generated CSS file:

/*! tailwindcss v4.0.0 | MIT License | https://tailwindcss.com */
@layer theme, base, components, utilities;
@layer theme {
  :root {
    ...

    --animate-fade-in-scale: fade-in-scale 0.3s ease-out;
  }
}

...

@keyframes fade-in-scale {
  0% {
    opacity: 0;
    transform: scale(0.95);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

The same goes for the default animations spin, ping, pulse and bounce. CSS properties and keyframes are included, only utility classes are not.

I would expect --animate-* variables and keyframes to only be included in the generated CSS file if they are actually used.

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