1import React from "react"
2
3import { cn } from "@/lib/utils"
4
5interface PulsatingButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
6 pulseColor?: string
7 duration?: string
8}
9
10export const PulsatingButton = React.forwardRef<
11 HTMLButtonElement,
12 PulsatingButtonProps
13>(
14 (
15 {
16 className,
17 children,
18 pulseColor = "#808080",
19 duration = "1.5s",
20 ...props
21 },
22 ref
23 ) => {
24 return (
25 <button
26 ref={ref}
27 className={cn(
28 "bg-primary text-primary-foreground relative flex cursor-pointer items-center justify-center rounded-lg px-4 py-2 text-center",
29 className
30 )}
31 style={
32 {
33 "--pulse-color": pulseColor,
34 "--duration": duration,
35 } as React.CSSProperties
36 }
37 {...props}
38 >
39 <div className="relative z-10">{children}</div>
40 <div className="absolute top-1/2 left-1/2 size-full -translate-x-1/2 -translate-y-1/2 animate-pulse rounded-lg bg-inherit" />
41 </button>
42 )
43 }
44)
45
46PulsatingButton.displayName = "PulsatingButton"
47