Free · MIT · React + Tailwind

Scroll Animation for React

A reusable reveal-on-scroll component powered by IntersectionObserver and Tailwind transitions. It runs once, avoids a heavy animation dependency and respects reduced-motion settings.

Observe
Reveal
Engage

Copy the code

'use client'
import { useEffect, useRef, useState } from 'react'
export function RevealOnScroll({ children }: { children: React.ReactNode }) {
  const ref = useRef<HTMLDivElement>(null)
  const [visible, setVisible] = useState(false)
  useEffect(() => {
    const node = ref.current
    if (!node) return
    const observer = new IntersectionObserver(([entry]) => { if (entry.isIntersecting) { setVisible(true); observer.disconnect() } }, { threshold: 0.2 })
    observer.observe(node)
    return () => observer.disconnect()
  }, [])
  return <div ref={ref} className={'transition duration-700 motion-reduce:transition-none ' + (visible ? 'translate-y-0 opacity-100' : 'translate-y-6 opacity-0')}>{children}</div>
}

Tailwind CSS · no dependencies · MIT licensed. Paste it straight into any React, Next.js or Vite project.

About the scroll animation

This scroll animation is part of Empire UI - a free, open-source library of 34+ component types rendered across 41 visual styles, from glassmorphism to neo-brutalism. Every block is copy-paste ready in React and Tailwind CSS with no runtime dependencies.

Want it in a different look? Browse all 41 styles or grab the matching glassmorphism components.