tailwindcss icon indicating copy to clipboard operation
tailwindcss copied to clipboard

Custom animations are not working when the prefix option is used

Open fatihsolhan opened this issue 5 years ago • 4 comments

What version of Tailwind CSS are you using?

v2.2.15

What browser are you using?

Chrome

What operating system are you using?

macOS

Reproduction URL

https://play.tailwindcss.com/lQHpW5ODct

Describe your issue

Custom animations are not working when tailwind is used with prefix option.

Steps to reproduce:

  • Open reproduction URL
  • replace tw-animate-shake class with animate-shake in HTML section
  • remove prefix: 'tw' in Config Section

It will work as expected without prefix.

fatihsolhan avatar Nov 25 '21 14:11 fatihsolhan

Steps are including . is not working. If I replace: '6.5%' with '10%'. That step is working fine.

Reproduction URL: https://play.tailwindcss.com/QxyE7NfLCA

So this is the same issue with https://github.com/tailwindlabs/tailwindcss/issues/2425 but this is happening when I use prefix option

fatihsolhan avatar Nov 25 '21 14:11 fatihsolhan

Yep @fatihsolhan, when you set the prefix, the prefix will also be inserted into the animation frames, ended with 6.5% => 6.tw-5\% and that will break your custom animation.

A quick workaround might be, remove the fractional parts.

4096void avatar Dec 01 '21 03:12 4096void

Thanks for the report! I just checked and the reproduction appears to work as expected in Tailwind CSS v3.0+

thecrypticace avatar Mar 01 '22 18:03 thecrypticace

Well with prefix like tw- it does seem to work but with a prefix like < it doesn't.

the prefix moves to the actual animation name so the css generated is

.\<animate-pulse {
    animation: <pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
} 

but the animation name is still pulse

I guess < and other characters are a bad prefix for tailwind, maybe put that in the doc somewhere?

see repro https://play.tailwindcss.com/F2twtDAK0K

deanshub avatar Jan 20 '23 08:01 deanshub