ComponentsButton Background Shine

Button Background Shine

Terminal
npm i clsx tailwind-merge
utils/cn.ts
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";

export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs));
}
ButtonBackgroundShine.tsx
import { cn } from "@/utils/cn";

export function ButtonBackgroundShine() {
  return (
    <button
      className={cn(
        "animate-shine items-center justify-center rounded-xl border border-white/10 bg-[linear-gradient(110deg,#000000,45%,#303030,55%,#000000)]",
        "bg-[length:400%_100%] px-4 py-2 text-sm font-medium text-neutral-200 transition-colors dark:border-neutral-800",
        "dark:bg-[linear-gradient(110deg,#000103,45%,#303030,55%,#000103)] dark:text-neutral-400",
      )}
    >
      Button
    </button>
  );
}
tailwind.config.ts
{
  "animation": {
    "shine": "shine 6s linear infinite"
  },
  "keyframes": {
    "shine": {
      "from": {
        "backgroundPosition": "0 0"
      },
      "to": {
        "backgroundPosition": "-400% 0"
      }
    }
  }
}