Radial Intro
animate-ui/components-community-radial-introFreeComponent
A circular intro animation component that arranges elements in a radial layout, smoothly transitioning them into orbit with looping motion.
Install it
npx shadcn@latest add https://animate-ui.com/r/components-community-radial-intro.jsonSource
1'use client';23import * as React from 'react';4import {5 LayoutGroup,6 motion,7 useAnimate,8 delay,9 type Transition,10 type AnimationSequence,11} from 'motion/react';1213interface ComponentProps {14 orbitItems: OrbitItem[];15 stageSize?: number;16 imageSize?: number;17}1819type OrbitItem = {20 id: number;21 name: string;22 src: string;23};2425const transition: Transition = {26 delay: 0,27 stiffness: 300,28 damping: 35,29 type: 'spring',30 restSpeed: 0.01,31 restDelta: 0.01,32};3334const spinConfig = {35 duration: 30,36 ease: 'linear' as const,37 repeat: Infinity,38};3940const qsa = (root: Element, sel: string) =>41 Array.from(root.querySelectorAll(sel));4243const angleOf = (el: Element) => Number((el as HTMLElement).dataset.angle || 0);4445const armOfImg = (img: Element) =>46 (img as HTMLElement).closest('[data-arm]') as HTMLElement | null;4748function RadialIntro({49 orbitItems,50 stageSize = 320,51 imageSize = 60,52}: ComponentProps) {53 const step = 360 / orbitItems.length;54 const [scope, animate] = useAnimate();5556 React.useEffect(() => {57 const root = scope.current;58 if (!root) return;5960 // get arm and image elements61 const arms = qsa(root, '[data-arm]');62 const imgs = qsa(root, '[data-arm-image]');63 const stops: Array<() => void> = [];6465 // image lift-in66 delay(() => animate(imgs, { top: 0 }, transition), 250);6768 // build sequence for orbit placement69 const orbitPlacementSequence: AnimationSequence = [70 ...arms.map((el): [Element, Record<string, any>, any] => [71 el,72 { rotate: angleOf(el) },73 { ...transition, at: 0 },74 ]),75 ...imgs.map((img): [Element, Record<string, any>, any] => [76 img,77 { rotate: -angleOf(armOfImg(img)!), opacity: 1 },78 { ...transition, at: 0 },79 ]),80 ];8182 // play placement sequence83 delay(() => animate(orbitPlacementSequence), 700);8485 // start continuous spin for arms and images86 delay(() => {87 // arms spin clockwise88 arms.forEach((el) => {89 const angle = angleOf(el);90 const ctrl = animate(el, { rotate: [angle, angle + 360] }, spinConfig);91 stops.push(() => ctrl.cancel());92 });9394 // images counter-spin to stay upright95 imgs.forEach((img) => {96 const arm = armOfImg(img);97 const angle = arm ? angleOf(arm) : 0;98 const ctrl = animate(99 img,100 { rotate: [-angle, -angle - 360] },101 spinConfig,102 );103 stops.push(() => ctrl.cancel());104 });105// … truncated
What it pulls in
npm packages
Files it writes
More from Animate UI
All 580 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Avatar Groupcomponents-animate-avatar-group | Animate UI | Components | Free | 1 dep | |
| Codecomponents-animate-code | Animate UI | Components | Free | 1 dep | |
| Code Tabscomponents-animate-code-tabs | Animate UI | Components | Free | 1 dep | |
| Cursorcomponents-animate-cursor | Animate UI | Components | Free | no deps | |
| GitHub Stars Wheelcomponents-animate-github-stars-wheel | Animate UI | Components | Free | 1 dep | |
| Tabscomponents-animate-tabs | Animate UI | Components | Free | no deps | |
| Tooltipcomponents-animate-tooltip | Animate UI | Components | Free | 1 dep | |
| Bubble Backgroundcomponents-backgrounds-bubble | Animate UI | Components | Free | 1 dep |
