The easiest way to animate your Tailwind React Components on scroll. Add life to your web app with simple yet powerful animations.
To use AOS for TailwindCSS + React, install the package via npm:
npm install aos-react-tailwind
First, import the Aos
component from the package:
import Aos from "aos-react-tailwind";
Then, wrap any component you want to animate inside Aos
and define the className
prop as a function that returns the TailwindCSS classes:
(...)
<Aos
className={(inView) => [
"opacity-0 duration-500",
inView && "opacity-1",
]}
>
<DogCard dog={dog} />
</Aos>
(...)
Aos
accepts all props that react-intersection-observer
does, along with the following:
className
: A function that receives inView
(a boolean indicating if the element is in the viewport) and returns the class names to be applied.Make sure to have TailwindCSS set up in your project, as this package is designed to be used in conjunction with it.
If you have suggestions for how AOS for TailwindCSS + React could be improved, or want to report a bug, open an issue! We'd love all and any contributions.
For more, check out the Contributing Guide.
AOS for TailwindCSS + React is MIT licensed.
This project is inspired by AOS - Animate on scroll library .
Give a ⭐️ if this project helped you!