Text Fill Animation
A scroll-driven color sweep brings text into focus one character at a time.
Scroll inside the preview to fill the text.
Component preview
Install using CLI
npx shadcn@latest add "https://www.obsidianui.dev/r/text-fill-animation.json"Usage
Code
"use client";
import { useRef } from "react";
import { TextFillAnimation } from "@/components/block/text-fill-animation";
export default function Demo() {
const scroller = useRef(null);
return (
<div ref={scroller} tabIndex={0} aria-label="Scroll to preview the text fill" className="h-[400px] overflow-y-auto overscroll-contain">
<TextFillAnimation
scroller={scroller}
height="850px"
viewportHeight="400px"
showDetails={false}
text="Make something worth remembering. Build your next idea with ObsidianUI."
textSize="2rem"
mobileTextSize="1.6rem"
tabletTextSize="2rem"
/>
</div>
);
}Install Manually
1
Install dependencies
npm install clsx gsap tailwind-merge
2
Copy the source code
Copy into components/block/text-fill-animation.jsx
3
Add the CSS file
Copy into components/block/text-fill-animation.css
4
Add the supporting file
Copy into lib/utils.ts
Preview behavior
Scroll inside the preview to fill the text. The effect stays inside its container and respects reduced motion preferences.
Last updated on