Animated Border Trail
Animated Border Trail is a React and Tailwind CSS component from Motion Primitives, licensed MIT. Copy it and paste it into your project.
Motion Primitives
MIT
other
What it is
Animated Border Trail is a React and Tailwind CSS component from Motion Primitives, licensed MIT. Copy it and paste it into your project.
How to use it
Open it in the catalogue, press copy, and paste it into your project. The prompt you copy carries the code and the rules that tell your agent to reproduce it without changing anything.
Five free copies a month. No card.
Needs
npm i motion
Licence
This component comes from Motion Primitives and is redistributed under the MIT licence, which permits commercial use. The copyright notice travels with the code.
Animated Border Trail
'use client';
import { cn } from '@/lib/utils';
import { motion, Transition } from 'motion/react';
export type BorderTrailProps = {
className?: string;
size?: number;
transition?: Transition;
onAnimationComplete?: () => void;
style?: React.CSSProperties;
};
export function BorderTrail({
className,
size = 60,
transition,
onAnimationComplete,
style,
}: BorderTrailProps) {
const defaultTransition: Transition = {
repeat: Infinity,
duration: 5,
ease: 'linear',
};
return (
<div className='pointer-events-none absolute inset-0 rounded-[inherit] border border-transparent [mask-clip:padding-box,border-box] [mask-composite:intersect] [mask-image:linear-gradient(transparent,transparent),linear-gradient(#000,#000)]'>
<motion.div
className={cn('absolute aspect-square bg-zinc-500', className)}
style={{
width: size,
offsetPath: `rect(0 auto auto 0 round ${size}px)`,
...style,
}}
animate={{
offsetDistance: ['0%', '100%'],
}}
transition={transition || defaultTransition}
onAnimationComplete={onAnimationComplete}
/>
</div>
);
}