Skip to content

Instantly share code, notes, and snippets.

@johnpolacek
Created March 7, 2023 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnpolacek/532fb439be85852a4b7fb7ffdef4e536 to your computer and use it in GitHub Desktop.
Save johnpolacek/532fb439be85852a4b7fb7ffdef4e536 to your computer and use it in GitHub Desktop.
Tailwind Component for Animate Fade-In and Up
import React, { useEffect, useState } from "react"
const FadeIn = ({
children,
}: {
children: JSX.Element | JSX.Element[] | string
}) => {
const [animate, setAnimate] = useState("opacity-0 translate-y-10")
useEffect(() => {
window.scrollTo(0, document.body.scrollHeight);
setAnimate("opacity-100 translate-y-0")
}, []);
return (
<div className={`transition-all ease-out duration-1000 ${animate}`}>
{children}
</div>
)
}
export default FadeIn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment