-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Default animation keyframes should respect prefix in config #2125
Comments
Interesting one for sure, I think I agree in principal but the challenge is how do we prefix the animation name reliably in the actual For example, given this config: module.exports = {
prefix: 'tw-',
theme: {
animation: {
wiggle: 'wiggle 1s ease-in-out infinite',
},
keyframes: {
wiggle: {
// ...
}
}
},
// ...
}; ...how do we prefix the instance of "wiggle" inside the Do we do a magic string substitution where we find any strings that match the name of a keyframe definition and prefix them? Is that too magic? Are there unintended side-effects of that? Do we have to make sure we only replace matches that are at the very beginning of the string? What if someone is deliberately trying to reference an animation they've defined in custom CSS and they don't want it prefixed? I guess only if it matches the keyframes name exactly we replace it? 🤔 Any thoughts on the most bullet proof way to do this that also follows the principle of least surprise? |
Ya, I get what you mean about how might be best to blend a customized Thoughts? |
Only issue with that is it's a breaking change, since someone may have defined a new custom animation entry that is reference an existing keyframes rule 🙁 Otherwise would 100% agree, bah. |
Gah, you are right haha - is there like a grace period where you can say "this has been in the wild less than 2 weeks, no complaints plz 😬" One option would be to introduce a second set (identical definitions, just updated names), mark the old as deprecated and move on. If someone is using the "old" names (spin, ping, etc) and they have no conflict with the names, you don't have to care. If they are using the old names and they have a conflict with the names, they will have a very simple remediation available in switching to the "new" names (tailwind-spin, etc). Ship both for two minor releases and then axe the old names - it's perfect 😄 |
If we deprecated the names how would that fix the collision issue for people using the prefix if we still include them? 🤔 |
The intention of shipping both for a time wouldn't be to fix the collision, it would be to provide a small transition window for users to become aware of the potential for collision and make the (almost certainly tiny) updates required to de-collide themselves by converting to the new names. This is a time when |
Just noticed that even with purge |
It is the default in PurgeCSS yeah, you need to add module.exports = {
purge: {
options: {
keyframes: true,
}
}
} |
Ah neat, I was actually removing them by disabling the animation property. |
A little bit of a side question, is there a way to prefix only animations and nothing else? I ran into an issue with TW animations overwrite by another lib since it's also using a pulse animation name, so I would rather call mine tw-pulse |
@adamwathan will it require to use a |
You can override the animations in your config file and name them whatever you want 👍🏻 |
@adamwathan but that will mean creating duplicated animations that do the same thing? tailwind.config.js
Or am I missing something? |
As long as you don't put them under module.exports = {
theme: {
keyframes: {
'tw-pulse': {
'0%, 100%': {opacity: 1},
'50%': {opacity: 0.5}
}
},
animation: {
'tw-pulse': 'tw-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite'
}
}
} But yes you will have to write out the values you want, and if you want to use the same values we use by default then you'll have to write those out or pull them in from |
Describe the problem:
Starting with
v1.6.0
, without any customization to the configuration there are animation utilities produced including@keyframes
values. The keyframes generated have names which are pretty common (spin
,ping
,pulse
, andbounce
) and when bringing tailwind into a codebase with existing styles, there's a nontrivial chance of name conflict with these names. My hope would be that the generated keyframes would respect the configprefix
value so that the names of the animation keyframes were, e.g.tw-spin
,tw-pulse
, etc.Obviously these names can be adjusted by changing the keyframes configuration settings (so this is not a breaking issue or at least it has a straight forward workaround), but given that these are produced by default, I think they should respect the
prefix
.Link to a minimal reproduction:
Using a stock
npx tailwindcss init
config file with theprefix
set will reproduce this:The text was updated successfully, but these errors were encountered: