1"use client"
2
3import * as React from "react"
4
5import { cn } from "@/lib/utils"
6
7interface ShineBorderProps extends React.HTMLAttributes<HTMLDivElement> {
8 /**
9 * Width of the border in pixels
10 * @default 1
11 */
12 borderWidth?: number
13 /**
14 * Duration of the animation in seconds
15 * @default 14
16 */
17 duration?: number
18 /**
19 * Color of the border, can be a single color or an array of colors
20 * @default "#000000"
21 */
22 shineColor?: string | string[]
23}
24
25/**
26 * Shine Border
27 *
28 * An animated background border effect component with configurable properties.
29 */
30export function ShineBorder({
31 borderWidth = 1,
32 duration = 14,
33 shineColor = "#000000",
34 className,
35 style,
36 ...props
37}: ShineBorderProps) {
38 return (
39 <div
40 style={
41 {
42 "--border-width": `${borderWidth}px`,
43 "--duration": `${duration}s`,
44 backgroundImage: `radial-gradient(transparent,transparent, ${
45 Array.isArray(shineColor) ? shineColor.join(",") : shineColor
46 },transparent,transparent)`,
47 backgroundSize: "300% 300%",
48 mask: `linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)`,
49 WebkitMask: `linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)`,
50 WebkitMaskComposite: "xor",
51 maskComposite: "exclude",
52 padding: "var(--border-width)",
53 ...style,
54 } as React.CSSProperties
55 }
56 className={cn(
57 "motion-safe:animate-shine pointer-events-none absolute inset-0 size-full rounded-[inherit] will-change-[background-position]",
58 className
59 )}
60 {...props}
61 />
62 )
63}
64