Shine Button

PreviousNext

Button with shine sweep effect on hover

Docs
animbitscomponent

Preview

Loading preview…
registry/new-york/animations/buttons/shine.tsx
"use client";
import { motion, type HTMLMotionProps } from "motion/react";
interface ShineButtonProps extends Omit<HTMLMotionProps<"button">, "animate"> {
  children: React.ReactNode;
  direction?: "left" | "right";
}
export function ShineButton({
  children,
  direction = "right",
  className,
  ...props
}: ShineButtonProps) {
  return (
    <motion.button
      className={`relative overflow-hidden ${className || ""}`}
      whileHover="hover"
      initial="initial"
      {...props}
    >
      {children}
      <motion.div
        className="absolute inset-0 w-full h-full pointer-events-none"
        style={{
          background:
            "linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent)",
        }}
        variants={{
          initial: {
            x: direction === "right" ? "-100%" : "100%",
          },
          hover: {
            x: direction === "right" ? "100%" : "-100%",
          },
        }}
        transition={{ duration: 0.6, ease: "easeInOut" }}
      />
    </motion.button>
  );
}

Installation

npx shadcn@latest add @animbits/buttons-shine

Usage

import { ButtonsShine } from "@/components/buttons-shine"
<ButtonsShine />