Animated Group
motion-primitives/animated-groupFreeComponent
A container component that applies coordinated animations to a group of child elements.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/ibelick/motion-primitives/HEAD/public/c/animated-group.jsonSource
1'use client';2import { ReactNode } from 'react';3import { motion, Variants } from 'motion/react';4import React from 'react';56export type PresetType =7 | 'fade'8 | 'slide'9 | 'scale'10 | 'blur'11 | 'blur-slide'12 | 'zoom'13 | 'flip'14 | 'bounce'15 | 'rotate'16 | 'swing';1718export type AnimatedGroupProps = {19 children: ReactNode;20 className?: string;21 variants?: {22 container?: Variants;23 item?: Variants;24 };25 preset?: PresetType;26 as?: React.ElementType;27 asChild?: React.ElementType;28};2930const defaultContainerVariants: Variants = {31 visible: {32 transition: {33 staggerChildren: 0.1,34 },35 },36};3738const defaultItemVariants: Variants = {39 hidden: { opacity: 0 },40 visible: { opacity: 1 },41};4243const presetVariants: Record<PresetType, Variants> = {44 fade: {},45 slide: {46 hidden: { y: 20 },47 visible: { y: 0 },48 },49 scale: {50 hidden: { scale: 0.8 },51 visible: { scale: 1 },52 },53 blur: {54 hidden: { filter: 'blur(4px)' },55 visible: { filter: 'blur(0px)' },56 },57 'blur-slide': {58 hidden: { filter: 'blur(4px)', y: 20 },59 visible: { filter: 'blur(0px)', y: 0 },60 },61 zoom: {62 hidden: { scale: 0.5 },63 visible: {64 scale: 1,65 transition: { type: 'spring', stiffness: 300, damping: 20 },66 },67 },68 flip: {69 hidden: { rotateX: -90 },70 visible: {71 rotateX: 0,72 transition: { type: 'spring', stiffness: 300, damping: 20 },73 },74 },75 bounce: {76 hidden: { y: -50 },77 visible: {78 y: 0,79 transition: { type: 'spring', stiffness: 400, damping: 10 },80 },81 },82 rotate: {83 hidden: { rotate: -180 },84 visible: {85 rotate: 0,86 transition: { type: 'spring', stiffness: 200, damping: 15 },87 },88 },89 swing: {90 hidden: { rotate: -10 },91 visible: {92 rotate: 0,93 transition: { type: 'spring', stiffness: 300, damping: 8 },94 },95 },96};9798const addDefaultVariants = (variants: Variants) => ({99 hidden: { ...defaultItemVariants.hidden, ...variants.hidden },100 visible: { ...defaultItemVariants.visible, ...variants.visible },101});102103function AnimatedGroup({104 children,105 className,106 variants,107 preset,108 as = 'div',109 asChild = 'div',110}: AnimatedGroupProps) {111 const selectedVariants = {112 item: addDefaultVariants(preset ? presetVariants[preset] : {}),113 container: addDefaultVariants(defaultContainerVariants),114 };115 const containerVariants = variants?.container || selectedVariants.container;116// … truncated
What it pulls in
npm packages
Files it writes
More from motion-primitives
All 33 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | motion-primitives | Components | Free | 1 dep | |
| Animated Backgroundanimated-background | motion-primitives | Components | Free | 1 dep | |
| Animated Numberanimated-number | motion-primitives | Components | Free | 1 dep | |
| Border Trailborder-trail | motion-primitives | Components | Free | 1 dep | |
| Carouselcarousel | motion-primitives | Components | Free | 1 dep | |
| Cursorcursor | motion-primitives | Components | Free | 1 dep | |
| Dialogdialog | motion-primitives | Components | Free | 1 dep · 2 files | |
| Disclosuredisclosure | motion-primitives | Components | Free | 1 dep |
