rainbow-button
jolyui-ui/rainbow-buttonFreeComponent
jolyui/ui publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by jolyui/ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://jolyui.dev/r/rainbow-button.jsonSource
1import { motion } from "motion/react";2import * as React from "react";3import { cn } from "@/lib/utils";45interface RainbowButtonProps6 extends React.ButtonHTMLAttributes<HTMLButtonElement> {7 children: React.ReactNode;8 colors?: string[];9 duration?: number;10 borderWidth?: number;11 animated?: boolean;12}1314const RainbowButton = React.forwardRef<HTMLButtonElement, RainbowButtonProps>(15 (16 {17 children,18 colors = ["#f43f5e", "#8b5cf6", "#3b82f6", "#22c55e", "#f43f5e"],19 duration = 2,20 borderWidth = 2,21 animated = true,22 className,23 onClick,24 disabled,25 type = "button",26 ...props27 },28 ref,29 ) => {30 const gradientColors = colors.join(", ");3132 return (33 <button34 ref={ref}35 type={type}36 onClick={onClick}37 disabled={disabled}38 className={cn(39 "relative inline-flex items-center justify-center overflow-hidden rounded-lg font-medium transition-transform hover:scale-105 active:scale-95 disabled:pointer-events-none disabled:opacity-50",40 className,41 )}42 style={{ padding: borderWidth }}43 {...props}44 >45 {/* Animated gradient background */}46 <motion.div47 className="absolute inset-0"48 style={{49 background: `linear-gradient(var(--gradient-angle, 0deg), ${gradientColors})`,50 }}51 animate={52 animated53 ? {54 "--gradient-angle": ["0deg", "360deg"],55 }56 : undefined57 }58 transition={59 animated60 ? {61 duration,62 repeat: Infinity,63 ease: "linear",64 }65 : undefined66 }67 />68 {/* Button content */}69 <span70 className="relative z-10 flex items-center gap-2 rounded-md bg-background px-6 py-2.5 font-medium text-sm transition-colors hover:bg-background/90"71 style={{72 borderRadius: `calc(0.5rem - ${borderWidth}px)`,73 }}74 >75 {children}76 </span>77 </button>78 );79 },80);81RainbowButton.displayName = "RainbowButton";8283export { RainbowButton };
What it pulls in
npm packages
Files it writes
More from jolyui/ui
All 199 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| ai-prompt-boxai-prompt-box | jolyui/ui | Components | Free | 4 deps | |
| animated-beamanimated-beam | jolyui/ui | Components | Free | 1 dep | |
| animated-tableanimated-table | jolyui/ui | Components | Free | 2 deps | |
| animated-theme-toggleanimated-theme-toggle | jolyui/ui | Components | Free | 2 deps | |
| animated-toastanimated-toast | jolyui/ui | Components | Free | 2 deps | |
| animated-tooltipanimated-tooltip | jolyui/ui | Components | Free | 1 dep | |
| bento-gridbento-grid | jolyui/ui | Components | Free | no deps | |
| buttonbutton | jolyui/ui | Components | Free | 3 deps |
