Files
webb/src/components/magicui/border-beam.tsx
T

67 lines
1.7 KiB
TypeScript
Raw Normal View History

'use client';
import React from 'react';
import { cn } from '@/lib/utils';
interface BorderBeamProps {
className?: string;
size?: number;
duration?: number;
borderWidth?: number;
anchor?: number;
colorFrom?: string;
colorTo?: string;
delay?: number;
}
export function BorderBeam({
className,
size = 250,
duration = 12,
borderWidth = 1.5,
anchor = 90,
colorFrom = '#3b82f6',
colorTo = '#8b5cf6',
delay = 0,
}: BorderBeamProps) {
return (
<div
style={
{
'--size': `${size}px`,
'--duration': `${duration}s`,
'--anchor': `${anchor}%`,
'--border-width': `${borderWidth}px`,
'--color-from': colorFrom,
'--color-to': colorTo,
'--delay': `-${delay}s`,
} as React.CSSProperties
}
className={cn(
'pointer-events-none absolute inset-0 rounded-[inherit] overflow-hidden',
className
)}
>
<div
className="absolute inset-0 rounded-[inherit]"
style={{
padding: `${borderWidth}px`,
mask: 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)',
WebkitMask: 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)',
maskComposite: 'exclude',
WebkitMaskComposite: 'xor',
}}
>
<div
className="absolute inset-[-100%] animate-spin pointer-events-none"
style={{
animationDuration: `${duration}s`,
animationDelay: `${delay}s`,
background: `conic-gradient(from 0deg at 50% 50%, transparent 0deg, transparent 270deg, ${colorFrom} 315deg, ${colorTo} 360deg)`,
}}
/>
</div>
</div>
);
}