-
Hello folks 👋 Love the new tailwind release. I have a question around how to give custom animation duration when the animation itself is given as a one off value. This is expanding on the general discussion i raised earlier. I am trying an animation like so:
I've defined
This works, but these are one-off values which i don't want to include in my
which will allow me to remove one-off's from my config, and keep the config truly for the theme related stuff? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
You can keep your original class name with the arbitrary values and simply remove the extended <div className="animate-[fadeIn_300ms_ease-out_900ms_forwards]" /> Results in: .animate-\[fadeIn_300ms_ease-out_900ms_forwards\] {
animation: fadeIn 300ms ease-out 900ms forwards;
} Proof with this Tailwind Play with a blank config. |
Beta Was this translation helpful? Give feedback.
-
Although it's an old question, I don't seem to find a way to actually solve the question in the title. |
Beta Was this translation helpful? Give feedback.
-
This might be helpful for folks who have a canned animation in their configuration like this: keyframes: {
fadeIn: {
'0%': { opacity: '0' },
'33%': { opacity: '0' },
'100%': { opacity: '1' }
},
},
animation: {
fadeIn: 'fadeIn 2s ease-in-out'
} Maybe I need it to be 2 seconds in most places, but that's really long. And all tailwind (3.4) generates for you is a single Well, thanks to arbitrary variants, even though tailwind doesn't currently provide an
And the 0.5s will win out over the 2s |
Beta Was this translation helpful? Give feedback.
-
{
plugins: [
// animation duration with arbitrary value support
plugin(function ({ matchUtilities, theme }) {
const durations = theme('transitionDuration'); // or define your own presets
matchUtilities(
{
'animation-duration': (value) => ({
'animation-duration': value,
}),
},
{ values: durations, type: 'any' },
);
}),
]
} <div class="tw-animation-duration-300"></div>
<div class="tw-animation-duration-[2500ms]"></div> |
Beta Was this translation helpful? Give feedback.
You can keep your original class name with the arbitrary values and simply remove the extended
animationDuration
andanimationDelay
configurations – the values used in the arbitrary class name are already contained because they are in the class name:Results in:
Proof with this Tailwind Play with a blank config.