Style Library
Transition Panel
AnimationanimationPrompt
Paste into any AI assistant before describing what to build — or attach it to a project below.
# Animation pattern — Transition Panel
Build it in React with `motion` (motion/react) and Tailwind CSS. Respect `prefers-reduced-motion` (render the final state without movement), keep it under ~400 ms for UI feedback, and animate only transform and opacity where possible.
Reference implementation (Motion-Primitives, MIT):
```tsx
'use client';
import {
AnimatePresence,
Transition,
Variant,
motion,
MotionProps,
} from 'motion/react';
import { cn } from '@/lib/utils';
export type TransitionPanelProps = {
children: React.ReactNode[];
className?: string;
transition?: Transition;
activeIndex: number;
variants?: { enter: Variant; center: Variant; exit: Variant };
} & MotionProps;
export function TransitionPanel({
children,
className,
transition,
variants,
activeIndex,
...motionProps
}: TransitionPanelProps) {
return (
<div className={cn('relative', className)}>
<AnimatePresence
initial={false}
mode='popLayout'
custom={motionProps.custom}
>
<motion.div
key={activeIndex}
variants={variants}
transition={transition}
initial='enter'
animate='center'
exit='exit'
{...motionProps}
>
{children[activeIndex]}
</motion.div>
</AnimatePresence>
</div>
);
}
```Use it in an app
Create a free account to attach this style to a project: the hub adds it to the prompt your AI assistant gets, so it builds every page in this look.
From Motion-Primitives (MIT, commit 120f64f).View source