Tailwindcss-motion is a TailwindCSS plugin that provides simple yet robust animations for your TailwindCSS-powered web projects.
It offers a straightforward syntax that allows developers to create smooth, performant animations without the complexity of custom keyframes.
Features
🎨 Simple Interface: The plugin offers an intuitive syntax that makes animation implementation quick and straightforward.
⚡ Performance Optimized: The plugin has been tested across different browsers to ensure compatibility and efficiency, removing the worry of performance issues.
♾️ Infinite Configurability: Tailwind CSS Motion allows developers to customize animations extensively to fit their project’s needs.
♿ Accessibility by Design: Animation accessibility is a priority, with built-in features that make animations friendly for all users.
Use Cases
- Dynamic User Interfaces: Enhance user interfaces with subtle animations for hover effects, transitions, and loading states. For instance, use
motion-preset-fadeto smoothly fade in content upon page load ormotion-preset-slide-rightfor a visually appealing navigation menu transition. - Interactive Elements: Create engaging interactive elements, such as animated buttons, tooltips, and modals. A button could use
motion-preset-bounceon hover, while a tooltip could utilizemotion-preset-slide-upfor a sleek appearance. - Attention-Grabbing Animations: Implement eye-catching animations for hero sections, call-to-action buttons, and promotional banners.
motion-preset-confettiadds a celebratory feel, whilemotion-preset-typewritercreates a unique text reveal animation. - Micro-interactions: Implement subtle micro-interactions to provide feedback and enhance user engagement. For example, a form submission could use
motion-preset-expandfor a successful animation. - Animated Data Visualizations: Add animation to charts and graphs to highlight data changes and trends. Utilize base animations like
motion-scale-in-75andmotion-rotate-in-180to draw attention to key information.
Installation
- Install the npm package:
npm i -D tailwindcss-motion- Add the plugin to your
tailwind.config.js:
// tailwind.config.js
export default {
content: [...],
theme: {
extend: {...},
},
plugins: [require('tailwindcss-motion')],
};Or, to use ESM:
import tailwindcssMotion from "tailwindcss-motion";
/** @type {import('tailwindcss').Config} */
export default {
content: [...],
theme: {
extend: {},
},
plugins: [tailwindcssMotion],
};Usage
Apply animation presets directly to HTML elements using utility classes:
<div class="motion-preset-fade">Fade-in effect</div>
<button class="motion-preset-bounce">Bounce on hover</button>Combine base animations for customized effects:
<div class="motion-scale-in-75 motion-translate-y-in-100">Scale and slide in</div>Modify animation properties with modifiers:
<div class="motion-duration-2000 motion-rotate-in-180">Rotate over 2 seconds</div>Motion Presets Available
Basic:
- Fade:
motion-preset-fade - Focus:
motion-preset-focus - Bounce:
motion-preset-bounce - Expand:
motion-preset-expand - Shrink:
motion-preset-shrink - Pop:
motion-preset-pop - Compress:
motion-preset-compress - Shake:
motion-preset-shake - Wiggle:
motion-preset-wiggle - Confetti:
motion-preset-confetti - Flomoji:
motion-preset-flomoji
Directional:
- Slide:
- Right:
motion-preset-slide-right - Left:
motion-preset-slide-left - Up:
motion-preset-slide-up - Down:
motion-preset-slide-down
- Right:
- Blur:
- Right:
motion-preset-blur-right - Left:
motion-preset-blur-left - Up:
motion-preset-blur-up - Down:
motion-preset-blur-down
- Right:
Text:
- Typewriter:
motion-preset-typewriter-[number of characters](e.g.,motion-preset-typewriter-10)
Related Resources
- Tailwind CSS Official Documentation: https://tailwindcss.com/ – The official documentation for Tailwind CSS.
- Animate.css: https://animate.style/ – A popular animation library providing a wide range of pre-built animations.
- Framer Motion: https://www.framer.com/motion/ – A production-ready motion library for React.
FAQs
Q: Does tailwindcss-motion work with all versions of Tailwind CSS?
A: Consult the official documentation for compatibility information.
Q: Can I create custom animation presets?
A: The plugin allows customization of existing presets and combination of base animations to achieve unique effects.
Q: How do I control the easing of animations?
A: Use the motion-timing utility classes to apply different easing functions.
Q: What are exit animations and how do I use them?
A: Replace in with out in the class A: name for the reverse animation. For instance, motion-opacity-in-0 becomes motion-opacity-out-0.
Q: Does Tailwind CSS Motion affect page performance?
A: No, the plugin uses optimized CSS transforms and transitions for smooth performance.
Q: Can I customize animation timing functions?
A: Yes, through built-in timing classes like motion-ease-spring-bouncy or motion-ease-bounce.
Q: Will animations work on mobile devices?
A: Yes, all animations are mobile-compatible and respect device performance capabilities.






