Timeline Animation

A timeline animation built with Framer Motion that animates sections one after another as they enter the viewport. Supports an animationNum prop to control when each item in the timeline animates.

Installation

npx uilayouts@latest add timeline-animation

Usage Examples

Default Animation

1
const timelineRef = useRef<HTMLDivElement>(null);
2
3
<TimelineAnimation as='h2' animationNum={1} ref={timelineRef}>
4
Default fade/slide animation
5
</TimelineAnimation>

Custom Variants

1
const timelineRef = useRef<HTMLDivElement>(null);
2
3
const revealVariants = {
4
hidden: { opacity: 0, scale: 0.8 },
5
visible: { opacity: 1, scale: 1, transition: { duration: 0.5 } },
6
};
7
8
<TimelineAnimation as='button' ref={timelineRef} animationNum={2} customVariants={revealVariants}>
9
Custom animation
10
</TimelineAnimation>;
1
const timelineRef = useRef<HTMLDivElement>(null);
2
3
<TimelineAnimation
4
as='a'
5
href='https://pro.ui-layouts.com/test'
6
animationNum={3}
7
customVariants={revealVariants}
8
ref={timelineRef}
9
className='group rounded-lg border p-4'
10
>
11
Clickable card
12
</TimelineAnimation>

Props

PropTypeDefaultDescription
childrenReact.ReactNodeThe content to be displayed within the timeline.
askeyof HTMLElementTagNameMap"div"The HTML element to render (div, a, section, etc.).
animationNumnumberA number used to stagger animations for multiple items.
viewport{ amount?: number; margin?: string; once?: boolean }{ amount: 0.3, margin: "0px 0px -120px 0px", once: true }Controls when the animation triggers in the viewport.
customVariantsVariantsOptional set of custom Framer Motion variants for hidden and visible animations.
classNamestringOptional CSS classes to style the timeline element.
delaybooleanOptional delay properties for adding delay animation between timeline.
...propsComponentPropsWithoutRef<T>All other native HTML props for the element (e.g., href, target, rel for <a>).