Components

Rainbow Button

A React rainbow button with a slowly scrolling gradient border, built on the DuskUI Button with Motion and Tailwind CSS. Pick a dark-filled or outline style, pass your own colors, and keep the width-stable loading state and every shadcn/ui Button prop.

  • Built on DuskUI Button
  • Animated gradient border
  • Custom colors
  • Loading state
  • prefers-reduced-motion

Installation

$ npx shadcn@latest add https://duskui.com/r/rainbow-button.json

Builds on the DuskUI Button; the CLI installs it automatically. Installing by hand? Add components/ui/button.tsx from the Button page first.

Usage

hero-cta.tsx
import { RainbowButton } from "@/components/dusk/rainbow-button/rainbow-button"

export function HeroCta() {
  return <RainbowButton size="lg">Get started</RainbowButton>
}

Examples

Colors & shape

Pass any list of CSS colors to colors — the loop is seamless. duration sets the seconds per cycle, borderWidth the line, and className can make it a pill.

Loading

The border is drawn on the button itself, so it keeps moving while loading crossfades the label to a spinner without changing the width.

API Reference

Also accepts every DuskUI Button prop (size, loading, loadingText, loaderIcon) and Motion props such as whileTap. asChild is not supported.

PropTypeDefaultDescription
variant"default" | "outline""default"Dark fill, or a see-through fill with a subtle hover background.
colorsstring[]5-color rainbowGradient colors in order; the last blends back into the first.
durationnumber6Seconds for the gradient to scroll one full cycle.
borderWidthnumber1Border width in px.
classNamestring—Merged with tailwind-merge, so overrides such as rounded-full win.

Accessibility

  • Renders a native <button>, so Enter, Space and focus order work as usual, with the standard DuskUI focus-visible ring.
  • Keyboard focus shows the standard focus ring.
  • The border is a pseudo-element, so they never reach screen readers or shift layout.
  • Loading keeps the button focusable (aria-busy + aria-disabled) instead of disabling it.
  • With prefers-reduced-motion the gradient stays still; it also pauses whenever the button is off-screen.