shadcn/ui animations not working on Tailwind v4
Dialogs and accordions without animation mean a missing tw-animate-css or shadcn/tailwind.css import. Why the second one fails silently, and how to check.
- shadcn 4.23.0
- Tailwind CSS 4.3.5
- Vite 8
- React 19.3
If shadcn/ui dialogs, sheets, popovers and accordions open and close without any animation on Tailwind CSS v4, one of two imports is missing from your main CSS file: @import "tw-animate-css"; or @import "shadcn/tailwind.css";. The build passes without either, which is why this takes people an afternoon to find. Here's how to tell which one, and the less common causes after that.
Check the two imports
A project made with shadcn init on CLI 4.23 starts like this:
@import "tailwindcss";@import "tw-animate-css";@import "shadcn/tailwind.css";Each does a different job:
tw-animate-cssdefines the animation utilities the components use:animate-in,animate-out,fade-in-0,zoom-in-95,slide-in-from-top-2andanimate-accordion-down.shadcn/tailwind.cssships with theshadcnpackage. It defines the accordion keyframes and thedata-open:,data-closed:,data-checked:and similar variants that the components put those animations behind.
We removed each import in turn from a working project with a Dialog and an Accordion, rebuilt it and counted what was left in the CSS:
| CSS file has | animate-in rules | Accordion keyframes | What you see |
|---|---|---|---|
| Both imports | yes | yes | Fade, zoom and slide work |
No tw-animate-css | none | none | Everything appears and disappears instantly |
No shadcn/tailwind.css | generated, but behind the wrong selector | partly | Same: no animation, no error |
Why a missing shadcn/tailwind.css fails silently
This one is worth understanding, because it also explains odd behaviour in components you write yourself. Tailwind v4 has a built-in data-* variant: data-open: means "when the element has a data-open attribute". Without shadcn's stylesheet, that's what you get:
grep -o '\.data-open\\:animate-in[^{]*{' dist/assets/*.css.data-open\:animate-in[data-open]{Radix doesn't set data-open. It sets data-state="open". So the rule exists and never matches. With the import back, shadcn's variant covers both conventions (Radix's data-state and Base UI's data-open):
grep -o '\.data-open\\:animate-in[^{]*{' dist/assets/*.css.data-open\:animate-in:where([data-state=open]),.data-open\:animate-in:where([data-open]:not([data-open=false])){The fix: put the import back, and make sure the shadcn package is still in your dependencies. People remove it because it looks like a CLI they only run with npx; the stylesheet lives in it.
Other causes
The old tailwindcss-animate plugin
Projects from before March 2025 used tailwindcss-animate, a v3 plugin. shadcn/ui replaced it with tw-animate-css. Uninstall the old one, install the new one and import it as above:
npm install tw-animate-csspnpm add tw-animate-cssyarn add tw-animate-cssbun add tw-animate-cssThen remove @plugin "tailwindcss-animate"; or the plugins entry from an old config, if you have one.
Not a cause: reduced motion
We checked the built CSS of our test project: the dialog and accordion animations don't look at the operating system's reduce-motion setting at all, so that setting won't switch them off. If you want it respected, and we think you should, add motion-reduce:animate-none to the animated elements, or a global rule under @media (prefers-reduced-motion: reduce).
A component copied from an older version
Older shadcn components wrote data-[state=open]:animate-in instead of data-open:animate-in. Both work with the imports in place. If you mix components from different versions and only some animate, compare their class strings with npx shadcn@latest add dialog --diff; updating components shows how to take the new version without losing your edits.
Questions
Do I need tailwindcss-animate with Tailwind v4?
No. Use tw-animate-css, a pure CSS replacement you import in your stylesheet. No plugin, no config.
Why is my accordion jumping open instead of sliding?
The slide uses animate-accordion-down, which needs both imports: the utility from tw-animate-css and the keyframes with the panel height variable from shadcn/tailwind.css.
Is this related to other Tailwind v4 problems?
Often. If more than animations look off, go through shadcn not working with Tailwind v4.
Related articles
- shadcn/uishadcn/ui not working with Tailwind v4: six causes and fixesUnstyled or transparent shadcn components on Tailwind v4 come from v3 leftovers: the old PostCSS plugin, @tailwind directives, hsl() wrappers, missing imports.
- shadcn/uiHow to update shadcn/ui components without losing your changesThere is no update command: use add --dry-run and --diff to see changes, --overwrite to take them, and Git to put your own edits back.
- shadcn/uishadcn/ui dark mode not working? Check these seven thingsIs the dark class on <html>? If not: no provider, a flash on load, or Astro view transitions. If it is: colours without a dark value or @theme without inline.
Still stuck? We answer every message ourselves. Write to us