Rainbow Button
A button component with animated rainbow gradient borders and background that continuously cycles through multiple vibrant colors. This eye-catching component is perfect for highlighting premium features or important calls-to-action.Installation
Usage
Examples
Basic Usage
Outline Variant
Different Sizes
Icon Button
As Link
Props
The content to display inside the button.
The visual style variant of the button:
default: Filled background with rainbow gradientoutline: Transparent background with rainbow border
The size of the button:
default: h-9 px-4 py-2sm: h-8 rounded-xl px-3 text-xslg: h-11 rounded-xl px-8icon: size-9 (square)
Additional CSS classes to apply to the button.
All standard HTML button or anchor attributes are supported. If
href is provided, the component renders as a link.Component Details
Animation Behavior
The Rainbow Button creates a mesmerizing color-cycling effect through:- Gradient Animation: A linear gradient moves through 5 color stops
- Border Integration: The gradient is applied to both the border and a blur effect below
- Smooth Transitions: Colors transition seamlessly with a 200% background size
- Infinite Loop: The animation repeats continuously
Color Customization
The rainbow colors are controlled via CSS variables:Animation Speed
Control the animation speed with the--speed CSS variable:
Keyframe Animation
The component requires this CSS keyframe (automatically included via registry):Tailwind Variants
The component usestailwind-variants for type-safe variant management:
Dependencies
bits-ui- For button/link component logictailwind-variants- For variant management- Tailwind CSS - For styling and animations
Accessibility
The component maintains full accessibility:- Semantic HTML (button or link depending on props)
- Keyboard navigation support
- Focus states with ring indicators
- Screen reader compatible
- Supports
disabledstate - ARIA attributes supported
Use Cases
The Rainbow Button is ideal for:- Premium features: Highlight paid or special features
- Call-to-action: Draw maximum attention to key actions
- Promotional content: Stand out in marketing materials
- Creative interfaces: Add personality to modern designs
- Special events: Celebrations, launches, or limited-time offers
Performance Notes
The animation uses CSS background-position which is hardware-accelerated. The component performs well even with multiple instances on the page.
Blur Effect
The component includes a subtle blur effect below the button using a::before pseudo-element. This is filtered out in the element to avoid affecting content.