Timeline Animation
atroui/timeline-animationFreeComponent
Scroll-linked sequenced motion for hero timelines.
Install it
npx shadcn@latest add https://atroui.com/r/timeline-animation.jsonSource
1"use client"23import type { Variants } from "motion/react"4import {5 type HTMLMotionProps,6 motion,7 useInView,8 useReducedMotion,9} from "motion/react"10import type React from "react"1112type TimelineContentProps<T extends keyof HTMLElementTagNameMap> = {13 children?: React.ReactNode14 animationNum: number15 className?: string16 timelineRef: React.RefObject<HTMLElement | null>17 as?: T18 customVariants?: Variants19 once?: boolean20} & HTMLMotionProps<T>2122export const TimelineAnimation = <23 T extends keyof HTMLElementTagNameMap = "div",24>({25 children,26 animationNum,27 timelineRef,28 className,29 as,30 customVariants,31 once = true,32 ...props33}: TimelineContentProps<T>) => {34 const reduce = useReducedMotion()3536 const defaultSequenceVariants: Variants = {37 visible: (i: number) => ({38 y: 0,39 opacity: 1,40 transition: {41 delay: reduce ? 0 : i * 0.5,42 duration: reduce ? 0 : 0.5,43 },44 }),45 hidden: {46 y: reduce ? 0 : 8,47 opacity: reduce ? 1 : 0,48 },49 }5051 const sequenceVariants = customVariants || defaultSequenceVariants5253 const isInView = useInView(timelineRef, {54 once,55 })5657 const MotionComponent = motion[as || "div"] as React.ElementType5859 return (60 <MotionComponent61 initial={reduce ? false : "hidden"}62 animate={reduce || isInView ? "visible" : "hidden"}63 custom={animationNum}64 variants={sequenceVariants}65 className={className}66 {...props}67 >68 {children}69 </MotionComponent>70 )71}
What it pulls in
npm packages
Files it writes
More from atroui
All 82 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Breadcrumbsbreadcrumbs | atroui | Components | Free | 2 deps | |
| Buttonbutton | atroui | Components | Free | 2 deps | |
| Cardcard | atroui | Components | Free | no deps | |
| Fade Infade-in | atroui | Components | Free | 1 dep | |
| Form Selectform-select | atroui | Components | Free | 2 deps | |
| Founder Avatarfounder-avatar | atroui | Components | Free | 1 dep | |
| Logologo | atroui | Components | Free | no deps | |
| Mockup Framemockup-frame | atroui | Components | Free | no deps |
