Skip to content

feat: add compatibility with tailwindcss v4 #63

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zbigniewstefaniuk
Copy link

@zbigniewstefaniuk zbigniewstefaniuk commented Nov 27, 2024

Hi there, huuge fan of tailwindcss-animate here

I've updated peer dependencies to play nicley with tailwind v4

@jamiebuilds

@kimonneuhoff
Copy link

@jamiebuilds can you please merge this pr? :)

@ktisakib
Copy link

please merge the pr we want to use v4 with this

@M-51
Copy link

M-51 commented Dec 23, 2024

In the meantime, you can override tailwindcss-animate peer dependency, by adding this:

 "overrides": {
    "tailwindcss-animate": {
      "tailwindcss": "$tailwindcss"
    }
  },

to your package.json.

tailwindcss-animate will use tailwindcss version specified in your package.json file.

@matthewgapp
Copy link

For those looking for a plug-n-play solution: I published a fork as a short-term workaround where I'm folding in some of the outstanding PRs, since this repo hasn't had activity in 2 years. https://github.com/nobie-org/tailwindcss-animate.

npm: https://www.npmjs.com/package/@nobie-org/tailwindcss-animate

@Wombosvideo
Copy link

Wombosvideo commented Jan 28, 2025

I've translated this plugin to the new CSS-first format and uploaded the code to https://github.com/Wombosvideo/tailwindcss-animate-v4. Maybe this helps someone

EDIT: Renamed it and wrapped it in an NPM package for easy updating.

@adielhercules
Copy link

I was having the same issue and found a workaround, I found this is working properly:

In your app.css, you can add the plugin like this:

@import "tailwindcss";
@plugin "tailwindcss-animate";
/* ... rest of theme and styles */

This is described in their documentation:

Use the @plugin directive to load a legacy JavaScript-based plugin

Link: https://tailwindcss.com/docs/functions-and-directives#plugin-directive

@Wombosvideo
Copy link

@adielhercules Sure but you will still get some glitches

@markosmk
Copy link

markosmk commented Feb 1, 2025

I've translated this plugin to the new CSS-first format and uploaded the code to https://github.com/Wombosvideo/tailwindcss-animate-v4. Maybe this helps someone

This is the best response, and better adapted to the V4 of Tailwindcss, thanks

@altanbgn
Copy link

altanbgn commented Feb 4, 2025

still not merged? It this project abandoned?

@WilsonNet
Copy link

@adielhercules Sure but you will still get some glitches

thank you so much, it worked, it is much prettier as a css file

@CarlosVergikosk
Copy link

@adielhercules thank you for merging this, im facing an issue where the vscode intellisense doesnt suggest me the animated classes. Any idea on how i can fix it? Thanks <3

@Wombosvideo
Copy link

im facing an issue where the vscode intellisense doesnt suggest me the animated classes.

Are you using a JavaScript or a CSS version of the plugin? If you are using a CSS version, v1.1 of tailwindcss-animate-v4 adds some IntelliSense suggestions. If you think some are still missing, feel free to create an issue or open a PR.

If you are using a JavaScript version, try checking the IntelliSense extension's log. My suggestions weren't working properly due to a missing config file.

@nikitadmitr
Copy link

I was having the same issue and found a workaround, I found this is working properly:

In your app.css, you can add the plugin like this:

@import "tailwindcss";
@plugin "tailwindcss-animate";
/* ... rest of theme and styles */

This is described in their documentation:

Use the @plugin directive to load a legacy JavaScript-based plugin

Link: https://tailwindcss.com/docs/functions-and-directives#plugin-directive

man, bless you

@GauthierPLM
Copy link

There was no commit for 2 years now. It's fair to consider the author is not maintaining this repo anymore.

@sina-ss
Copy link

sina-ss commented Mar 9, 2025

I don't think this pr accept soon...

@Wombosvideo
Copy link

@markosmk @WilsonNet

I've updated tailwindcss-animate-v4, renamed it to tw-animate-css and wrapped in an NPM package for easy updating. Let me know if you run into any problems

https://github.com/wombosvideo/tw-animate-css

npm install tw-animate-css
@import "tw-animate-css"

@trenaryja
Copy link

#63 (comment)

@markosmk @WilsonNet

I've updated tailwindcss-animate-v4, renamed it to tw-animate-css and wrapped in an NPM package for easy updating. Let me know if you run into any problems

https://github.com/wombosvideo/tw-animate-css

npm install tw-animate-css
@import "tw-animate-css"

@Wombosvideo thank you for making this. Tested and working with tailwind v4.0.14 in a nextjs app. It's a single clean file as well, which makes it easy to just copy and place in into my own project. I hope more folks follow that approach, but I also hope @shadcn updates to point to tw-animate-css instead of tailwindcss-animate going forward for tailwind v4!

Thanks again, works like a charm!

@nrjdalal
Copy link

nrjdalal commented Mar 17, 2025

@Wombosvideo I've updated tailwindcss-animate-v4, renamed it to tw-animate-css.

tailwindcss's naming convention for plugins is like @tailwindcss/something

considering that isn't better name tailwindcss-animations, tailwindcss-animate-css, or just tailwind-animate

tw is considered for prefixing and merging libraries, tw isn't considered as an easy search either

@Wombosvideo
Copy link

tailwindcss's naming convention for plugins is like @tailwindcss/something

This may be true for their plugins due to being authored by tailwindcss. Generally the @ prefix for an NPM package indicates a specific ownership, or more specifically, a scope. Check the NPM docs on this. Also, I am sure the Tailwind team themselves will migrate their legacy JavaScript plugins to CSS files eventually (or integrate their functionality in Tailwind itself) as they are only in the v3 docs but not in the v4 docs.

considering that isn't better name tailwindcss-animations, tailwindcss-animate-css, or just tailwind-animate

While these names are good suggestions, those packages already exist or are too similar to packages which already exist. NPM actively prevents you from naming packages like this, see this comment.

tw is considered for prefixing and merging libraries

tw are two letters many people use to abbreviate the name Tailwind. They are in no way reserved for specific purposes.

tw isn't considered as an easy search either

Yes, I totally agree and I sadly also noticed this. I try to work around this by using tailwind in the keywords and README.

@nrjdalal
Copy link

tailwindcss's naming convention for plugins is like @tailwindcss/something

This may be true for their plugins due to being authored by tailwindcss. Generally the @ prefix for an NPM package indicates a specific ownership, or more specifically, a scope. Check the NPM docs on this. Also, I am sure the Tailwind team themselves will migrate their legacy JavaScript plugins to CSS files eventually (or integrate their functionality in Tailwind itself) as they are only in the v3 docs but not in the v4 docs.

considering that isn't better name tailwindcss-animations, tailwindcss-animate-css, or just tailwind-animate

While these names are good suggestions, those packages already exist or are too similar to packages which already exist. NPM actively prevents you from naming packages like this, see this comment.

tw is considered for prefixing and merging libraries

tw are two letters many people use to abbreviate the name Tailwind. They are in no way reserved for specific purposes.

tw isn't considered as an easy search either

Yes, I totally agree and I sadly also noticed this. I try to work around this by using tailwind in the keywords and README.

was not talking about @ prefix, I know @tailwindcss is taken by team tailwindcss, that aside, congratulation amigo, it made it in shadcn

what do you think bout adding, accordion animations directly to tw-animate-css, so shadcn config can be all about colors

  --animate-accordion-down: accordion-down 0.2s ease-out;
  --animate-accordion-up: accordion-up 0.2s ease-out;

  @keyframes accordion-down {
    from {
      height: 0;
    }
    to {
      height: var(--radix-accordion-content-height);
    }
  }

  @keyframes accordion-up {
    from {
      height: var(--radix-accordion-content-height);
    }
    to {
      height: 0;
    }
  }

@Wombosvideo
Copy link

that aside, congratulation amigo, it made it in shadcn

Thank you very much!

what do you think bout adding, accordion animations directly to tw-animate-css, so shadcn config can be all about colors

While this is a great idea, I wrote this CSS file with shadcn-svelte in mind, which uses different variable names (bits instead of radix) for the heights. Sure, I could just add multiple CSS variables and let the browser handle falling back to the next variable name if one does not exist. My prefered approach to this, however, would be to name it more generally (collapse-open and collapse-close) or something like that. Let's further discuss this in a new feature request or discussion so we can include the community in the decision-making.

@nrjdalal
Copy link

nrjdalal commented Mar 17, 2025

that aside, congratulation amigo, it made it in shadcn

Thank you very much!

what do you think bout adding, accordion animations directly to tw-animate-css, so shadcn config can be all about colors

While this is a great idea, I wrote this CSS file with shadcn-svelte in mind, which uses different variable names (bits instead of radix) for the heights. Sure, I could just add multiple CSS variables and let the browser handle falling back to the next variable name if one does not exist. My prefered approach to this, however, would be to name it more generally (collapse-open and collapse-close) or something like that. Let's further discuss this in a new feature request or discussion so we can include the community in the decision-making.

created an pull request just in case before getting your reply, will take it forward from there

Wombosvideo/tw-animate-css#12

@nrjdalal
Copy link

nrjdalal commented Mar 17, 2025

@Wombosvideo added accordion with support for both bits and radix in the PR

Wombosvideo/tw-animate-css#12

@nrjdalal
Copy link

nrjdalal commented Mar 17, 2025

that aside, congratulation amigo, it made it in shadcn

Thank you very much!

what do you think bout adding, accordion animations directly to tw-animate-css, so shadcn config can be all about colors

While this is a great idea, I wrote this CSS file with shadcn-svelte in mind, which uses different variable names (bits instead of radix) for the heights. Sure, I could just add multiple CSS variables and let the browser handle falling back to the next variable name if one does not exist. My prefered approach to this, however, would be to name it more generally (collapse-open and collapse-close) or something like that. Let's further discuss this in a new feature request or discussion so we can include the community in the decision-making.

also changing the naming convention to collapse-open and collapse-close would mean changing the shadcn accordion component in the registry, and would have impact on legacy migration where people won't update the components themselves

plus if you had to do that manually previously, to add support for bits, it's your decision as author to create better future and support for upcoming devs and create an impact

it is highly unlikely that we would have major voting participation in fast moving sense, be the change you seek in the world 😄

@nrjdalal

This comment was marked as resolved.

@Wombosvideo
Copy link

reduces 20 lines of code

No, it just moves them to your package

@nrjdalal

This comment was marked as resolved.

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.