Baktiyar Ablaikhan

Text Reveal

Source
Magic UI ↗
Author
Magic UI
Licence
MIT

Loading…

Scrolling the panel lights up a sentence word by word.

Code

"use client";

import { useRef } from "react";

import { TextReveal } from "@/lab/magicui/ui/text-reveal";

export default function TextRevealDemo() {
  const ref = useRef<HTMLDivElement>(null);
  return (
    <div className="relative h-full w-full">
      <div ref={ref} className="h-full w-full overflow-y-auto">
        <TextReveal container={ref}>Magic UI will change the way you design.</TextReveal>
      </div>
      <span className="pointer-events-none absolute top-3 right-4 font-mono text-[10px] tracking-widest text-neutral-400 uppercase">
        scroll ↓
      </span>
    </div>
  );
}
Prompt

Build "Text Reveal", a scroll animation. What it does: Scrolling the panel lights up a sentence word by word. Write it as a single self-contained React component in TypeScript that fills its parent (w-full h-full), styled with Tailwind CSS, using motion. Technique: the Motion library. It sits on a light background, in a 16:10 frame. Respect prefers-reduced-motion with a still state, pause work when the element is off screen, and keep it accessible. Original: https://magicui.design/docs/components/text-reveal (Magic UI, MIT).