tailwindcss-motion is a Tailwind CSS Plugin made at RomboHQ. It’s a simple, yet powerful, animation library with a simple syntax.
Motion, without commotion.
1. Install npm package
npm i -D tailwindcss-motion
2. Add into 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],
};
We provide a simple syntax to animate any element in your Tailwind project. Instead of defining custom keyframes, we provide utility classes to animate every dimension, inline.
For example, for a slide and fade effect — you simply need motion-translate-x-in-25 motion-opacity-in-0
or, you can use one of our presets with motion-preset-fade
We provide a collection of presets to animate your components easily:
motion-preset-fade
motion-preset-slide-right
motion-preset-slide-left
motion-preset-slide-up
motion-preset-slide-down
motion-preset-focus
motion-preset-blur-right
motion-preset-blur-left
motion-preset-blur-up
motion-preset-blur-down
motion-preset-bounce
motion-preset-expand
motion-preset-shrink
motion-preset-pop
motion-preset-compress
motion-preset-shake
motion-preset-wiggle
motion-preset-confetti
motion-preset-typewriter-[number of characters]
motion-preset-flomoji
You can further customize presets using base animations and modifiers classes.
For example:
motion-preset-fade
:<div class="motion-preset-fade motion-delay-500"></div>
motion-preset-slide-right
:<div class="motion-preset-slide-right motion-duration-2000"></div>
motion-preset-bounce
:<div class="motion-preset-bounce -motion-translate-y-in-150"></div>
Appart from presets, you can create your own custom animations by combining these base classes:
motion-opacity-in-0
motion-translate-y-in-100
-motion-translate-y-in-100
motion-scale-in-75
motion-rotate-in-180
-motion-rotate-in-90
motion-blur-in-sm
motion-grayscale-in
motion-bg-in-red-500
motion-text-in-blue-500
You can combine multiple animations on a single element:
<div
class="motion-scale-in-75 motion-translate-y-in-100 motion-rotate-in-90"
></div>
For exit animations, simply replace in
with out
in the class name.
You can customize the duration, delay, and timing function of any animation.
motion-duration-500
motion-delay-500
motion-timing-spring-bouncy
For example:
<div
class="motion-duration-2000 motion-rotate-in-180 motion-opacity-in-0"
></div>
This applies a duration of 2000ms to both the rotation and opacity animations.
You can apply modifiers to specific properties using a slash /
.
For example:
<div
class="motion-delay-500/rotate motion-rotate-in-180 motion-opacity-in-0"
></div>
Here, the delay of 500ms is applied only to the rotation, not the opacity.
The plugin includes custom timing functions:
a few examples are:
motion-ease-spring-smooth
motion-ease-spring-snappy
motion-ease-spring-bouncy
motion-ease-spring-bounciest
motion-ease-bounce
motion-ease-bounce
motion-ease-in-quart
Landing page - https://play.tailwindcss.com/uAuVF8F1vC
Chat dialog - https://play.tailwindcss.com/gjGqEKswjQ
Low Battery Dynamic Island - https://play.tailwindcss.com/tvYFbHtNNQ
Apple Color Swatches - https://play.tailwindcss.com/cvQ3Nk3v8j
Rombo is an early-stage company, building tools to help companies build beautiful interactive interfaces. We're starting out with a toolkit for engineers, designers and creative marketers to animate natively inside common Workflows — like Tailwind, Figma, Webflow, Shopify & more to come! Sign up for updates on our site at https://rombo.co