-
-
Notifications
You must be signed in to change notification settings - Fork 429
[Bug]: Accordion collapse animation does not work (in Nuxt) #1166
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
Comments
First thing I would check is if you can use any of the classes from Tailwind Animate this will ensure you have the dependency added and installed correctly as a tailwind plugin. I think though that the underlying animation library needs to be updated per this issue on that repo jamiebuilds/tailwindcss-animate#63 (comment) Edit: I guess there is an updated version it is referencing here tw-animate-css I would just make sure that you can use the classes yourself first to ensure that the package is installed correctly. |
@kennyhei did you find a solution to this? |
Yep, I have "dependencies": {
"@nuxt/eslint": "^1.3.0",
"@nuxtjs/i18n": "^9.5.3",
"@tailwindcss/vite": "^4.1.3",
"@vueuse/core": "^13.1.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"eslint": "^9.24.0",
"lucide-vue-next": "^0.487.0",
"nuxt": "^3.16.2",
"reka-ui": "^2.2.0",
"tailwind-merge": "^3.2.0",
"tailwindcss": "^4.1.3",
"vue": "^3.5.13",
"vue-router": "^4.5.0"
},
"devDependencies": {
"prettier": "^3.5.3",
"shadcn-nuxt": "^2.0.0",
"tw-animate-css": "^1.2.5",
"typescript": "^5.8.3"
} The basic examples mentioned here https://github.com/jamiebuilds/tailwindcss-animate/blob/main/README.md work. Also I have sheet component installed and the slide animation in it also works without problems. |
I managed to find workaround by looking at reka-ui's documentation: https://reka-ui.com/docs/components/accordion#animating-content-size I copied this CSS from there to my /* styles.css */
.AccordionContent {
overflow: hidden;
}
.AccordionContent[data-state="open"] {
animation: slideDown 300ms ease-out;
}
.AccordionContent[data-state="closed"] {
animation: slideUp 300ms ease-out;
}
@keyframes slideDown {
from {
height: 0;
}
to {
height: var(--reka-accordion-content-height);
}
}
@keyframes slideUp {
from {
height: var(--reka-accordion-content-height);
}
to {
height: 0;
}
} And then added EDIT: If you want to simplify this even further without the need of touching @theme inline {
...
--animate-accordion-down: slideDown 0.3s ease-out;
--animate-accordion-up: slideUp 0.3s ease-out;
}
@keyframes slideDown {
from {
height: 0;
}
to {
height: var(--reka-accordion-content-height);
}
}
@keyframes slideUp {
from {
height: var(--reka-accordion-content-height);
}
to {
height: 0;
}
} And it should work. |
Yes, I also faced this issue a week ago. Just adding more context. It seems that animations in tailwind V4 are using tw-animate-css, which is using the Not sure what is the best approach to do this, just wanted to point it out. Right now, I had to download the tw-animate-css file and modify it and include it manually. Here is the file for reference file. |
Reproduction
Couldn't get codesandbox working
Describe the bug
Couldn't get codesandbox or stackblitz env working as I had problems with both when trying to setup nuxt + shadcn-vue + accordion component. Worked fine with e.g. button component though but got mysterious errors with accordion.
Here's my nuxt.config.ts:
I have also added
@import "tw-animate-css";
intailwind.css
(and installed said package). Btw, instructions for installingtw-animate-css
are missing from https://www.shadcn-vue.com/docs/installation/nuxt.html but are found in https://www.shadcn-vue.com/docs/installation/manual.html. Installingshadcn-nuxt
did not automatically include it.Anyway, animation does not work when collapsing / opening accordion item. It seems that
--radix-accordion-content-height
and--bits-accordion-content-height
are not computed properly as they both are undefined when I inspected accordion item's CSS using Chrome DevTools.System Info
Contributes
The text was updated successfully, but these errors were encountered: