Rainbow Button

A vibrant button with an animated rainbow gradient border and subtle glow, adding a playful pop of color on hover and interaction.

Installation

npx shadcn@latest add https://fluxbuttons.vercel.app/r/rainbow-button.json
rainbow-button.tsx
"use client";

import * as React from "react";
import { cn } from "@/lib/utils";

export interface RainbowButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {}

const RainbowButton = React.forwardRef<HTMLButtonElement, RainbowButtonProps>(
({ className, children, ...props }, ref) => {
  return (
    <button
      ref={ref}
      className={cn(
        "items-center bg-black  justify-center whitespace-nowrap rounded-md text-md font-medium transition-transform duration-200 ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group relative animate-rainbow cursor-pointer border-0 bg-[linear-gradient(#fff,#fff),linear-gradient(#fff_50%,rgba(255,255,255,0.6)_80%,rgba(0,0,0,0)),linear-gradient(90deg,hsl(0,100%,63%),hsl(90,100%,63%),hsl(210,100%,63%),hsl(195,100%,63%),hsl(270,100%,63%))] bg-[length:200%]  dark:text-neutral-300 text-neutral-300 hover:text-neutral-200 [background-clip:padding-box,border-box,border-box] [background-origin:border-box] [border:calc(0.08*1rem)_solid_transparent] before:absolute before:bottom-[-20%] before:left-1/2 before:z-[0] before:h-[20%] before:w-[60%] before:-translate-x-1/2 before:animate-rainbow before:bg-[linear-gradient(90deg,hsl(0,100%,63%),hsl(90,100%,63%),hsl(210,100%,63%),hsl(195,100%,63%),hsl(270,100%,63%))] before:[filter:blur(calc(0.8*1rem))] bg-[linear-gradient(#121213,#121213),linear-gradient(#121213_50%,rgba(18,18,19,0.6)_80%,rgba(18,18,19,0)),linear-gradient(90deg,hsl(0,100%,63%),hsl(90,100%,63%),hsl(210,100%,63%),hsl(195,100%,63%),hsl(270,100%,63%))] hover:scale-105 active:scale-95 h-10 px-8 py-2  inline-flex",
        className,
      )}
      {...props}
    >
      {children}
    </button>
  );
},
);

RainbowButton.displayName = "RainbowButton";

export default RainbowButton;

Usage

usage.tsx
import RainbowButton from "@/components/ui/rainbow-button";

const RainbowButtonPreview = () => {
  return <RainbowButton>Rainbow Button</RainbowButton>;
};

export default RainbowButtonPreview;

API Reference

Rainbow Button

Prop

Type

On this page