Animations add life to objects.
It’s used to represent emotions, unique ideas, flow, and feelings sometimes. That said, A picture says more than words and animation can convey more than a picture.
Days are gone when web designers were using .gif files to show some animations. It’s relevant to use CSS animations instead of using external files(you never know, that can make your site slow! 😨).
However, CSS provides the facility to apply animations, we will discuss how to add custom animations using Tailwind CSS in this blog.
Animation is imagination
Here, I’m assuming you’re ready with the tailwind CSS setup. No worries, if you’re not ready yet, please refer to configure tailwind CSS. Setup is very easy.
Let’s get started!
We are what we repeatedly do. Excellence, then, is not an act, but a habit. Try out Justly and start building your habits today!
Let’s overlook the main CSS properties that are responsible for animations.
It’s the same we used to use for CSS animation. It’s used to modify a set of styles at a specific time(many times).
It’s a shorthand property for setting all the animation properties like,
Let’s quickly go through how we can modify tailwind.config.js to create custom animations.
/** @type {import('tailwindcss').Config} */module.exports = {
content: [],
theme: {
extend: {
keyframes: {},
animation: {},
},
},
plugins: [],
}
In theme/extend block we can add keyframes and animation properties of custom animations.
By default, Tailwind CSS comes up with 4 built-in animations, which can also be modified using the tailwind.config.js file.
Let’s modify the above properties and create amazing animations.
However, it’s possible to use CSS styles inside keyframes and animation without specifying it in a tailwind config file.
Consider a case when you need to use rotate with negative digits, that do not default available in a tailwind.
You have just created a custom animation 🎉, it can now be used as the “animate-animation_name” class. for ex. animate-wiggle
Please note that every property used for animation, animation-duration, animation-delay, animation-iteration-count can be modified as well.
Here, the class will be accessible as animate-hflip.
Here, the class will be accessible as animate-vflip.
However, rotate3d() is not provided by a tailwind, it can be still used as a core CSS property with keyframes configuration.
However, scale3d() is not provided by a tailwind, it can be still used as a core CSS property with keyframes configuration.
Find all the animations at tailwind play.
The above-added animations can be customized according to requirements. Also, it can be explored further with the help of transform properties.
Be creative, create amazing !!