Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

fix: button types and component export standard improvement (#492)

Arghya Dase0fbe78804ca
diff --git a/content/docs/components/animated-subscribe-button.mdx b/content/docs/components/animated-subscribe-button.mdx
index 5f17aa9b..c40c7874 100644
--- a/content/docs/components/animated-subscribe-button.mdx
+++ b/content/docs/components/animated-subscribe-button.mdx
@@ -42,13 +42,11 @@ npx shadcn@latest add "https://magicui.design/r/animated-subscribe-button"
## Props
-| Prop | Type | Default | Description |
-| ----------------- | --------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `buttonColor` | `string` | `-` | The accent color for the button. This allows you to set a custom color that matches your brand's theme. |
-| `buttonTextColor` | `string` | `-` | The color of the button text. This allows you to ensure the text is visible and matches your desired color scheme. |
-| `subscribeStatus` | `boolean` | `-` | A boolean flag to check the condition for the button. This property can be used to toggle the button's state, such as subscribed or unsubscribed. |
-| `initialText` | `string` | `-` | The initial text displayed on the button. This is useful for setting a default label when the button first appears. |
-| `changeText` | `string` | `-` | The final text displayed on the button after an action has been taken. This can be used to indicate a state change, such as from "Subscribe" to "Subscribed". |
+| Prop | Type | Default | Description |
+| ----------------- | ----------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `subscribeStatus` | `boolean` | `false` | A boolean flag to check the condition for the button. This property can be used to toggle the button's state, such as subscribed or unsubscribed. |
+| `children` | `React.ReactNode` | `-` | The content to be displayed inside the button. Should contain two children - first for unsubscribed state and second for subscribed state. |
+| `className` | `string` | `-` | Optional class name to be applied to the button for custom styling. |
## Credits
diff --git a/public/r/styles/default/animated-subscribe-button.json b/public/r/styles/default/animated-subscribe-button.json
index bddefac7..fb26aba1 100644
--- a/public/r/styles/default/animated-subscribe-button.json
+++ b/public/r/styles/default/animated-subscribe-button.json
@@ -7,7 +7,7 @@
"files": [
{
"path": "magicui/animated-subscribe-button.tsx",
- "content": "\"use client\";\n\nimport { AnimatePresence, motion } from \"motion/react\";\nimport React, { useState } from \"react\";\n\ninterface AnimatedSubscribeButtonProps {\n buttonColor: string;\n buttonTextColor?: string;\n subscribeStatus: boolean;\n initialText: React.ReactElement | string;\n changeText: React.ReactElement | string;\n}\n\nexport const AnimatedSubscribeButton: React.FC<\n AnimatedSubscribeButtonProps\n> = ({\n buttonColor,\n subscribeStatus,\n buttonTextColor,\n changeText,\n initialText,\n}) => {\n const [isSubscribed, setIsSubscribed] = useState<boolean>(subscribeStatus);\n\n return (\n <AnimatePresence mode=\"wait\">\n {isSubscribed ? (\n <motion.button\n className=\"relative flex h-10 w-[200px] items-center justify-center overflow-hidden rounded-md bg-white outline outline-1 outline-black\"\n onClick={() => setIsSubscribed(false)}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n >\n <motion.span\n key=\"action\"\n className=\"relative flex h-full w-full items-center justify-center font-semibold\"\n initial={{ y: -50 }}\n animate={{ y: 0 }}\n style={{ color: buttonColor }}\n >\n {changeText}\n </motion.span>\n </motion.button>\n ) : (\n <motion.button\n className=\"relative flex h-10 w-[200px] cursor-pointer items-center justify-center rounded-md border-none\"\n style={{ backgroundColor: buttonColor, color: buttonTextColor }}\n onClick={() => setIsSubscribed(true)}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n >\n <motion.span\n key=\"reaction\"\n className=\"relative flex items-center justify-center font-semibold\"\n initial={{ x: 0 }}\n exit={{ x: 50, transition: { duration: 0.1 } }}\n >\n {initialText}\n </motion.span>\n </motion.button>\n )}\n </AnimatePresence>\n );\n};\n",
+ "content": "\"use client\";\n\nimport { HTMLMotionProps } from \"motion/react\";\nimport { AnimatePresence, motion } from \"motion/react\";\nimport React, { useState } from \"react\";\n\ninterface AnimatedSubscribeButtonProps extends HTMLMotionProps<\"button\"> {\n buttonColor: string;\n buttonTextColor?: string;\n subscribeStatus: boolean;\n initialText: React.ReactElement | string;\n changeText: React.ReactElement | string;\n ref?: React.Ref<HTMLButtonElement>;\n}\n\nexport const AnimatedSubscribeButton = React.forwardRef<\n HTMLButtonElement,\n AnimatedSubscribeButtonProps\n>(\n (\n {\n buttonColor,\n subscribeStatus,\n buttonTextColor,\n changeText,\n initialText,\n onClick,\n ...props\n },\n ref\n ) => {\n const [isSubscribed, setIsSubscribed] = useState<boolean>(subscribeStatus);\n\n return (\n <AnimatePresence mode=\"wait\">\n {isSubscribed ? (\n <motion.button\n ref={ref}\n className=\"relative flex h-10 w-[200px] items-center justify-center overflow-hidden rounded-md bg-white outline outline-1 outline-black\"\n onClick={(e: React.MouseEvent<HTMLButtonElement>) => {\n setIsSubscribed(false);\n onClick?.(e);\n }}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n {...props}\n >\n <motion.span\n ref={ref}\n key=\"action\"\n className=\"relative flex h-full w-full items-center justify-center font-semibold\"\n initial={{ y: -50 }}\n animate={{ y: 0 }}\n style={{ color: buttonColor }}\n >\n {changeText}\n </motion.span>\n </motion.button>\n ) : (\n <motion.button\n className=\"relative flex h-10 w-[200px] cursor-pointer items-center justify-center rounded-md border-none\"\n style={{ backgroundColor: buttonColor, color: buttonTextColor }}\n onClick={(e) => {\n setIsSubscribed(true);\n onClick?.(e);\n }}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n {...props}\n >\n <motion.span\n key=\"reaction\"\n className=\"relative flex items-center justify-center font-semibold\"\n initial={{ x: 0 }}\n exit={{ x: 50, transition: { duration: 0.1 } }}\n >\n {initialText}\n </motion.span>\n </motion.button>\n )}\n </AnimatePresence>\n );\n }\n);\n\nAnimatedSubscribeButton.displayName = \"AnimatedSubscribeButton\";\n",
"type": "registry:ui",
"target": ""
}
diff --git a/public/r/styles/default/interactive-hover-button.json b/public/r/styles/default/interactive-hover-button.json
index 719c8380..0c488f69 100644
--- a/public/r/styles/default/interactive-hover-button.json
+++ b/public/r/styles/default/interactive-hover-button.json
@@ -1,9 +1,7 @@
{
"name": "interactive-hover-button",
"type": "registry:ui",
- "dependencies": [
- "lucide-react"
- ],
+ "dependencies": ["lucide-react"],
"files": [
{
"path": "magicui/interactive-hover-button.tsx",
@@ -12,4 +10,4 @@
"target": ""
}
]
-}
\ No newline at end of file
+}
diff --git a/public/r/styles/default/pulsating-button.json b/public/r/styles/default/pulsating-button.json
index 9d9cb995..79ba9cad 100644
--- a/public/r/styles/default/pulsating-button.json
+++ b/public/r/styles/default/pulsating-button.json
@@ -4,7 +4,7 @@
"files": [
{
"path": "magicui/pulsating-button.tsx",
- "content": "\"use client\";\n\nimport React from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\ninterface PulsatingButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n pulseColor?: string;\n duration?: string;\n}\n\nexport default function PulsatingButton({\n className,\n children,\n pulseColor = \"#0096ff\",\n duration = \"1.5s\",\n ...props\n}: PulsatingButtonProps) {\n return (\n <button\n className={cn(\n \"relative flex cursor-pointer items-center justify-center rounded-lg bg-blue-500 px-4 py-2 text-center text-white dark:bg-blue-500 dark:text-black\",\n className,\n )}\n style={\n {\n \"--pulse-color\": pulseColor,\n \"--duration\": duration,\n } as React.CSSProperties\n }\n {...props}\n >\n <div className=\"relative z-10\">{children}</div>\n <div className=\"absolute left-1/2 top-1/2 size-full -translate-x-1/2 -translate-y-1/2 animate-pulse rounded-lg bg-inherit\" />\n </button>\n );\n}\n",
+ "content": "\"use client\";\n\nimport React from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\ninterface PulsatingButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n pulseColor?: string;\n duration?: string;\n}\n\nexport const PulsatingButton = React.forwardRef<\n HTMLButtonElement,\n PulsatingButtonProps\n>(\n (\n {\n className,\n children,\n pulseColor = \"#0096ff\",\n duration = \"1.5s\",\n ...props\n },\n ref,\n ) => {\n return (\n <button\n className={cn(\n \"relative flex cursor-pointer items-center justify-center rounded-lg bg-blue-500 px-4 py-2 text-center text-white dark:bg-blue-500 dark:text-black\",\n className,\n )}\n style={\n {\n \"--pulse-color\": pulseColor,\n \"--duration\": duration,\n } as React.CSSProperties\n }\n {...props}\n >\n <div className=\"relative z-10\">{children}</div>\n <div className=\"absolute left-1/2 top-1/2 size-full -translate-x-1/2 -translate-y-1/2 animate-pulse rounded-lg bg-inherit\" />\n </button>\n );\n },\n);\n\nPulsatingButton.displayName = \"PulsatingButton\";\n",
"type": "registry:ui",
"target": ""
}
diff --git a/public/r/styles/default/rainbow-button.json b/public/r/styles/default/rainbow-button.json
index ff3fe9c4..b117e8b0 100644
--- a/public/r/styles/default/rainbow-button.json
+++ b/public/r/styles/default/rainbow-button.json
@@ -4,7 +4,7 @@
"files": [
{
"path": "magicui/rainbow-button.tsx",
- "content": "import React from \"react\";\n\nimport { cn } from \"@/lib/utils\";\ninterface RainbowButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement> {}\n\nexport function RainbowButton({\n children,\n className,\n ...props\n}: RainbowButtonProps) {\n return (\n <button\n className={cn(\n \"group relative inline-flex h-11 animate-rainbow cursor-pointer items-center justify-center rounded-xl border-0 bg-[length:200%] px-8 py-2 font-medium text-primary-foreground transition-colors [background-clip:padding-box,border-box,border-box] [background-origin:border-box] [border:calc(0.08*1rem)_solid_transparent] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\",\n\n // before styles\n \"before:absolute before:bottom-[-20%] before:left-1/2 before:z-0 before:h-1/5 before:w-3/5 before:-translate-x-1/2 before:animate-rainbow before:bg-[linear-gradient(90deg,hsl(var(--color-1)),hsl(var(--color-5)),hsl(var(--color-3)),hsl(var(--color-4)),hsl(var(--color-2)))] before:[filter:blur(calc(0.8*1rem))]\",\n\n // light mode colors\n \"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(var(--color-1)),hsl(var(--color-5)),hsl(var(--color-3)),hsl(var(--color-4)),hsl(var(--color-2)))]\",\n\n // dark mode colors\n \"dark: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(var(--color-1)),hsl(var(--color-5)),hsl(var(--color-3)),hsl(var(--color-4)),hsl(var(--color-2)))]\",\n\n className,\n )}\n {...props}\n >\n {children}\n </button>\n );\n}\n",
+ "content": "\"use client\";\n\nimport React from \"react\";\nimport { cn } from \"@/lib/utils\";\n\ninterface RainbowButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement> {}\n\nexport const RainbowButton = React.forwardRef<\n HTMLButtonElement,\n RainbowButtonProps\n>(({ children, className, ...props }, ref) => {\n return (\n <button\n ref={ref}\n className={cn(\n \"group relative inline-flex h-11 animate-rainbow cursor-pointer items-center justify-center rounded-xl border-0 bg-[length:200%] px-8 py-2 font-medium text-primary-foreground transition-colors [background-clip:padding-box,border-box,border-box] [background-origin:border-box] [border:calc(0.08*1rem)_solid_transparent] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\",\n // before styles\n \"before:absolute before:bottom-[-20%] before:left-1/2 before:z-0 before:h-1/5 before:w-3/5 before:-translate-x-1/2 before:animate-rainbow before:bg-[linear-gradient(90deg,hsl(var(--color-1)),hsl(var(--color-5)),hsl(var(--color-3)),hsl(var(--color-4)),hsl(var(--color-2)))] before:[filter:blur(calc(0.8*1rem))]\",\n // light mode colors\n \"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(var(--color-1)),hsl(var(--color-5)),hsl(var(--color-3)),hsl(var(--color-4)),hsl(var(--color-2)))]\",\n // dark mode colors\n \"dark: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(var(--color-1)),hsl(var(--color-5)),hsl(var(--color-3)),hsl(var(--color-4)),hsl(var(--color-2)))]\",\n className,\n )}\n {...props}\n >\n {children}\n </button>\n );\n});\n\nRainbowButton.displayName = \"RainbowButton\";\n",
"type": "registry:ui",
"target": ""
}
diff --git a/public/r/styles/default/ripple-button.json b/public/r/styles/default/ripple-button.json
index c3d396c6..80ec50de 100644
--- a/public/r/styles/default/ripple-button.json
+++ b/public/r/styles/default/ripple-button.json
@@ -4,7 +4,7 @@
"files": [
{
"path": "magicui/ripple-button.tsx",
- "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport React, { MouseEvent, useEffect, useState } from \"react\";\n\ninterface RippleButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n rippleColor?: string;\n duration?: string;\n}\n\nconst RippleButton = React.forwardRef<HTMLButtonElement, RippleButtonProps>(\n (\n {\n className,\n children,\n rippleColor = \"#ffffff\",\n duration = \"600ms\",\n onClick,\n ...props\n },\n ref,\n ) => {\n const [buttonRipples, setButtonRipples] = useState<\n Array<{ x: number; y: number; size: number; key: number }>\n >([]);\n\n const handleClick = (event: MouseEvent<HTMLButtonElement>) => {\n createRipple(event);\n onClick?.(event);\n };\n\n const createRipple = (event: MouseEvent<HTMLButtonElement>) => {\n const button = event.currentTarget;\n const rect = button.getBoundingClientRect();\n const size = Math.max(rect.width, rect.height);\n const x = event.clientX - rect.left - size / 2;\n const y = event.clientY - rect.top - size / 2;\n\n const newRipple = { x, y, size, key: Date.now() };\n setButtonRipples((prevRipples) => [...prevRipples, newRipple]);\n };\n\n useEffect(() => {\n if (buttonRipples.length > 0) {\n const lastRipple = buttonRipples[buttonRipples.length - 1];\n const timeout = setTimeout(() => {\n setButtonRipples((prevRipples) =>\n prevRipples.filter((ripple) => ripple.key !== lastRipple.key),\n );\n }, parseInt(duration));\n return () => clearTimeout(timeout);\n }\n }, [buttonRipples, duration]);\n\n return (\n <button\n className={cn(\n \"relative flex cursor-pointer items-center justify-center overflow-hidden rounded-lg border-2 bg-background px-4 py-2 text-center text-primary\",\n className,\n )}\n onClick={handleClick}\n ref={ref}\n {...props}\n >\n <div className=\"relative z-10\">{children}</div>\n <span className=\"pointer-events-none absolute inset-0\">\n {buttonRipples.map((ripple) => (\n <span\n className=\"absolute animate-rippling rounded-full bg-background opacity-30\"\n key={ripple.key}\n style={{\n width: `${ripple.size}px`,\n height: `${ripple.size}px`,\n top: `${ripple.y}px`,\n left: `${ripple.x}px`,\n backgroundColor: rippleColor,\n transform: `scale(0)`,\n }}\n />\n ))}\n </span>\n </button>\n );\n },\n);\n\nRippleButton.displayName = \"RippleButton\";\n\nexport default RippleButton;\n",
+ "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport React, { MouseEvent, useEffect, useState } from \"react\";\n\ninterface RippleButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n rippleColor?: string;\n duration?: string;\n}\n\nexport const RippleButton = React.forwardRef<\n HTMLButtonElement,\n RippleButtonProps\n>(\n (\n {\n className,\n children,\n rippleColor = \"#ffffff\",\n duration = \"600ms\",\n onClick,\n ...props\n },\n ref,\n ) => {\n const [buttonRipples, setButtonRipples] = useState<\n Array<{ x: number; y: number; size: number; key: number }>\n >([]);\n\n const handleClick = (event: MouseEvent<HTMLButtonElement>) => {\n createRipple(event);\n onClick?.(event);\n };\n\n const createRipple = (event: MouseEvent<HTMLButtonElement>) => {\n const button = event.currentTarget;\n const rect = button.getBoundingClientRect();\n const size = Math.max(rect.width, rect.height);\n const x = event.clientX - rect.left - size / 2;\n const y = event.clientY - rect.top - size / 2;\n\n const newRipple = { x, y, size, key: Date.now() };\n setButtonRipples((prevRipples) => [...prevRipples, newRipple]);\n };\n\n useEffect(() => {\n if (buttonRipples.length > 0) {\n const lastRipple = buttonRipples[buttonRipples.length - 1];\n const timeout = setTimeout(() => {\n setButtonRipples((prevRipples) =>\n prevRipples.filter((ripple) => ripple.key !== lastRipple.key),\n );\n }, parseInt(duration));\n return () => clearTimeout(timeout);\n }\n }, [buttonRipples, duration]);\n\n return (\n <button\n className={cn(\n \"relative flex cursor-pointer items-center justify-center overflow-hidden rounded-lg border-2 bg-background px-4 py-2 text-center text-primary\",\n className,\n )}\n onClick={handleClick}\n ref={ref}\n {...props}\n >\n <div className=\"relative z-10\">{children}</div>\n <span className=\"pointer-events-none absolute inset-0\">\n {buttonRipples.map((ripple) => (\n <span\n className=\"absolute animate-rippling rounded-full bg-background opacity-30\"\n key={ripple.key}\n style={{\n width: `${ripple.size}px`,\n height: `${ripple.size}px`,\n top: `${ripple.y}px`,\n left: `${ripple.x}px`,\n backgroundColor: rippleColor,\n transform: `scale(0)`,\n }}\n />\n ))}\n </span>\n </button>\n );\n },\n);\n\nRippleButton.displayName = \"RippleButton\";\n",
"type": "registry:ui",
"target": ""
}
diff --git a/public/r/styles/default/shimmer-button.json b/public/r/styles/default/shimmer-button.json
index b90a50b6..d05fe9e9 100644
--- a/public/r/styles/default/shimmer-button.json
+++ b/public/r/styles/default/shimmer-button.json
@@ -4,7 +4,7 @@
"files": [
{
"path": "magicui/shimmer-button.tsx",
- "content": "import React, { CSSProperties } from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\nexport interface ShimmerButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n shimmerColor?: string;\n shimmerSize?: string;\n borderRadius?: string;\n shimmerDuration?: string;\n background?: string;\n className?: string;\n children?: React.ReactNode;\n}\n\nconst ShimmerButton = React.forwardRef<HTMLButtonElement, ShimmerButtonProps>(\n (\n {\n shimmerColor = \"#ffffff\",\n shimmerSize = \"0.05em\",\n shimmerDuration = \"3s\",\n borderRadius = \"100px\",\n background = \"rgba(0, 0, 0, 1)\",\n className,\n children,\n ...props\n },\n ref,\n ) => {\n return (\n <button\n style={\n {\n \"--spread\": \"90deg\",\n \"--shimmer-color\": shimmerColor,\n \"--radius\": borderRadius,\n \"--speed\": shimmerDuration,\n \"--cut\": shimmerSize,\n \"--bg\": background,\n } as CSSProperties\n }\n className={cn(\n \"group relative z-0 flex cursor-pointer items-center justify-center overflow-hidden whitespace-nowrap border border-white/10 px-6 py-3 text-white [background:var(--bg)] [border-radius:var(--radius)] dark:text-black\",\n \"transform-gpu transition-transform duration-300 ease-in-out active:translate-y-px\",\n className,\n )}\n ref={ref}\n {...props}\n >\n {/* spark container */}\n <div\n className={cn(\n \"-z-30 blur-[2px]\",\n \"absolute inset-0 overflow-visible [container-type:size]\",\n )}\n >\n {/* spark */}\n <div className=\"absolute inset-0 h-[100cqh] animate-shimmer-slide [aspect-ratio:1] [border-radius:0] [mask:none]\">\n {/* spark before */}\n <div className=\"absolute -inset-full w-auto rotate-0 animate-spin-around [background:conic-gradient(from_calc(270deg-(var(--spread)*0.5)),transparent_0,var(--shimmer-color)_var(--spread),transparent_var(--spread))] [translate:0_0]\" />\n </div>\n </div>\n {children}\n\n {/* Highlight */}\n <div\n className={cn(\n \"insert-0 absolute size-full\",\n\n \"rounded-2xl px-4 py-1.5 text-sm font-medium shadow-[inset_0_-8px_10px_#ffffff1f]\",\n\n // transition\n \"transform-gpu transition-all duration-300 ease-in-out\",\n\n // on hover\n \"group-hover:shadow-[inset_0_-6px_10px_#ffffff3f]\",\n\n // on click\n \"group-active:shadow-[inset_0_-10px_10px_#ffffff3f]\",\n )}\n />\n\n {/* backdrop */}\n <div\n className={cn(\n \"absolute -z-20 [background:var(--bg)] [border-radius:var(--radius)] [inset:var(--cut)]\",\n )}\n />\n </button>\n );\n },\n);\n\nShimmerButton.displayName = \"ShimmerButton\";\n\nexport default ShimmerButton;\n",
+ "content": "import React, { CSSProperties } from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\nexport interface ShimmerButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n shimmerColor?: string;\n shimmerSize?: string;\n borderRadius?: string;\n shimmerDuration?: string;\n background?: string;\n className?: string;\n children?: React.ReactNode;\n}\n\nexport const ShimmerButton = React.forwardRef<\n HTMLButtonElement,\n ShimmerButtonProps\n>(\n (\n {\n shimmerColor = \"#ffffff\",\n shimmerSize = \"0.05em\",\n shimmerDuration = \"3s\",\n borderRadius = \"100px\",\n background = \"rgba(0, 0, 0, 1)\",\n className,\n children,\n ...props\n },\n ref\n ) => {\n return (\n <button\n style={\n {\n \"--spread\": \"90deg\",\n \"--shimmer-color\": shimmerColor,\n \"--radius\": borderRadius,\n \"--speed\": shimmerDuration,\n \"--cut\": shimmerSize,\n \"--bg\": background,\n } as CSSProperties\n }\n className={cn(\n \"group relative z-0 flex cursor-pointer items-center justify-center overflow-hidden whitespace-nowrap border border-white/10 px-6 py-3 text-white [background:var(--bg)] [border-radius:var(--radius)] dark:text-black\",\n \"transform-gpu transition-transform duration-300 ease-in-out active:translate-y-px\",\n className\n )}\n ref={ref}\n {...props}\n >\n {/* spark container */}\n <div\n className={cn(\n \"-z-30 blur-[2px]\",\n \"absolute inset-0 overflow-visible [container-type:size]\"\n )}\n >\n {/* spark */}\n <div className=\"absolute inset-0 h-[100cqh] animate-shimmer-slide [aspect-ratio:1] [border-radius:0] [mask:none]\">\n {/* spark before */}\n <div className=\"absolute -inset-full w-auto rotate-0 animate-spin-around [background:conic-gradient(from_calc(270deg-(var(--spread)*0.5)),transparent_0,var(--shimmer-color)_var(--spread),transparent_var(--spread))] [translate:0_0]\" />\n </div>\n </div>\n {children}\n\n {/* Highlight */}\n <div\n className={cn(\n \"insert-0 absolute size-full\",\n\n \"rounded-2xl px-4 py-1.5 text-sm font-medium shadow-[inset_0_-8px_10px_#ffffff1f]\",\n\n // transition\n \"transform-gpu transition-all duration-300 ease-in-out\",\n\n // on hover\n \"group-hover:shadow-[inset_0_-6px_10px_#ffffff3f]\",\n\n // on click\n \"group-active:shadow-[inset_0_-10px_10px_#ffffff3f]\"\n )}\n />\n\n {/* backdrop */}\n <div\n className={cn(\n \"absolute -z-20 [background:var(--bg)] [border-radius:var(--radius)] [inset:var(--cut)]\"\n )}\n />\n </button>\n );\n }\n);\n\nShimmerButton.displayName = \"ShimmerButton\";\n",
"type": "registry:ui",
"target": ""
}
diff --git a/public/r/styles/default/shiny-button.json b/public/r/styles/default/shiny-button.json
index 51563e77..1a6fd807 100644
--- a/public/r/styles/default/shiny-button.json
+++ b/public/r/styles/default/shiny-button.json
@@ -7,7 +7,7 @@
"files": [
{
"path": "magicui/shiny-button.tsx",
- "content": "\"use client\";\n\nimport React from \"react\";\nimport {\n motion,\n type AnimationProps,\n type HTMLMotionProps,\n} from \"motion/react\";\nimport { cn } from \"@/lib/utils\";\n\nconst animationProps = {\n initial: { \"--x\": \"100%\", scale: 0.8 },\n animate: { \"--x\": \"-100%\", scale: 1 },\n whileTap: { scale: 0.95 },\n transition: {\n repeat: Infinity,\n repeatType: \"loop\",\n repeatDelay: 1,\n type: \"spring\",\n stiffness: 20,\n damping: 15,\n mass: 2,\n scale: {\n type: \"spring\",\n stiffness: 200,\n damping: 5,\n mass: 0.5,\n },\n },\n} as AnimationProps;\n\ninterface ShinyButtonProps extends HTMLMotionProps<\"button\"> {\n children: React.ReactNode;\n className?: string;\n ref?: React.Ref<HTMLButtonElement>;\n}\n\nconst ShinyButton = React.forwardRef<HTMLButtonElement, ShinyButtonProps>(\n ({ children, className, ...props }, ref) => {\n return (\n <motion.button\n ref={ref}\n {...animationProps}\n {...props}\n className={cn(\n \"relative rounded-lg px-6 py-2 font-medium backdrop-blur-xl transition-shadow duration-300 ease-in-out hover:shadow dark:bg-[radial-gradient(circle_at_50%_0%,hsl(var(--primary)/10%)_0%,transparent_60%)] dark:hover:shadow-[0_0_20px_hsl(var(--primary)/10%)]\",\n className,\n )}\n >\n <span\n className=\"relative block size-full text-sm uppercase tracking-wide text-[rgb(0,0,0,65%)] dark:font-light dark:text-[rgb(255,255,255,90%)]\"\n style={{\n maskImage:\n \"linear-gradient(-75deg,hsl(var(--primary)) calc(var(--x) + 20%),transparent calc(var(--x) + 30%),hsl(var(--primary)) calc(var(--x) + 100%))\",\n }}\n >\n {children}\n </span>\n <span\n style={{\n mask: \"linear-gradient(rgb(0,0,0), rgb(0,0,0)) content-box,linear-gradient(rgb(0,0,0), rgb(0,0,0))\",\n maskComposite: \"exclude\",\n }}\n className=\"absolute inset-0 z-10 block rounded-[inherit] bg-[linear-gradient(-75deg,hsl(var(--primary)/10%)_calc(var(--x)+20%),hsl(var(--primary)/50%)_calc(var(--x)+25%),hsl(var(--primary)/10%)_calc(var(--x)+100%))] p-px\"\n ></span>\n </motion.button>\n );\n },\n);\n\nShinyButton.displayName = \"ShinyButton\";\n\nexport default ShinyButton;\n",
+ "content": "\"use client\";\n\nimport React from \"react\";\nimport {\n motion,\n type AnimationProps,\n type HTMLMotionProps,\n} from \"motion/react\";\nimport { cn } from \"@/lib/utils\";\n\nconst animationProps = {\n initial: { \"--x\": \"100%\", scale: 0.8 },\n animate: { \"--x\": \"-100%\", scale: 1 },\n whileTap: { scale: 0.95 },\n transition: {\n repeat: Infinity,\n repeatType: \"loop\",\n repeatDelay: 1,\n type: \"spring\",\n stiffness: 20,\n damping: 15,\n mass: 2,\n scale: {\n type: \"spring\",\n stiffness: 200,\n damping: 5,\n mass: 0.5,\n },\n },\n} as AnimationProps;\n\ninterface ShinyButtonProps extends HTMLMotionProps<\"button\"> {\n children: React.ReactNode;\n className?: string;\n ref?: React.Ref<HTMLButtonElement>;\n}\n\nexport const ShinyButton = React.forwardRef<\n HTMLButtonElement,\n ShinyButtonProps\n>(({ children, className, ...props }, ref) => {\n return (\n <motion.button\n ref={ref}\n {...animationProps}\n {...props}\n className={cn(\n \"relative rounded-lg px-6 py-2 font-medium backdrop-blur-xl transition-shadow duration-300 ease-in-out hover:shadow dark:bg-[radial-gradient(circle_at_50%_0%,hsl(var(--primary)/10%)_0%,transparent_60%)] dark:hover:shadow-[0_0_20px_hsl(var(--primary)/10%)]\",\n className\n )}\n >\n <span\n className=\"relative block size-full text-sm uppercase tracking-wide text-[rgb(0,0,0,65%)] dark:font-light dark:text-[rgb(255,255,255,90%)]\"\n style={{\n maskImage:\n \"linear-gradient(-75deg,hsl(var(--primary)) calc(var(--x) + 20%),transparent calc(var(--x) + 30%),hsl(var(--primary)) calc(var(--x) + 100%))\",\n }}\n >\n {children}\n </span>\n <span\n style={{\n mask: \"linear-gradient(rgb(0,0,0), rgb(0,0,0)) content-box,linear-gradient(rgb(0,0,0), rgb(0,0,0))\",\n maskComposite: \"exclude\",\n }}\n className=\"absolute inset-0 z-10 block rounded-[inherit] bg-[linear-gradient(-75deg,hsl(var(--primary)/10%)_calc(var(--x)+20%),hsl(var(--primary)/50%)_calc(var(--x)+25%),hsl(var(--primary)/10%)_calc(var(--x)+100%))] p-px\"\n ></span>\n </motion.button>\n );\n});\n\nShinyButton.displayName = \"ShinyButton\";\n",
"type": "registry:ui",
"target": ""
}
diff --git a/registry/default/example/animated-subscribe-button-demo.tsx b/registry/default/example/animated-subscribe-button-demo.tsx
index fd7659d5..de1c01f5 100644
--- a/registry/default/example/animated-subscribe-button-demo.tsx
+++ b/registry/default/example/animated-subscribe-button-demo.tsx
@@ -1,25 +1,17 @@
import { CheckIcon, ChevronRightIcon } from "lucide-react";
-
import { AnimatedSubscribeButton } from "@/registry/default/magicui/animated-subscribe-button";
export default function AnimatedSubscribeButtonDemo() {
return (
- <AnimatedSubscribeButton
- buttonColor="#000000"
- buttonTextColor="#ffffff"
- subscribeStatus={false}
- initialText={
- <span className="group inline-flex items-center">
- Subscribe{" "}
- <ChevronRightIcon className="ml-1 size-4 transition-transform duration-300 group-hover:translate-x-1" />
- </span>
- }
- changeText={
- <span className="group inline-flex items-center">
- <CheckIcon className="mr-2 size-4" />
- Subscribed{" "}
- </span>
- }
- />
+ <AnimatedSubscribeButton className="w-36">
+ <span className="group inline-flex items-center">
+ Follow
+ <ChevronRightIcon className="ml-1 size-4 transition-transform duration-300 group-hover:translate-x-1" />
+ </span>
+ <span className="group inline-flex items-center">
+ <CheckIcon className="mr-2 size-4" />
+ Subscribed
+ </span>
+ </AnimatedSubscribeButton>
);
}
diff --git a/registry/default/example/interactive-hover-button-demo.tsx b/registry/default/example/interactive-hover-button-demo.tsx
index 32b9e6ef..ba214d8f 100644
--- a/registry/default/example/interactive-hover-button-demo.tsx
+++ b/registry/default/example/interactive-hover-button-demo.tsx
@@ -1,9 +1,5 @@
-import InteractiveHoverButton from "@/registry/default/magicui/interactive-hover-button";
+import { InteractiveHoverButton } from "@/registry/default/magicui/interactive-hover-button";
export default function InteractiveHoverButtonDemo() {
- return (
- <div className="relative justify-center">
- <InteractiveHoverButton />
- </div>
- );
+ return <InteractiveHoverButton>Hover Me</InteractiveHoverButton>;
}
diff --git a/registry/default/example/pulsating-button-demo.tsx b/registry/default/example/pulsating-button-demo.tsx
index 5de7a523..8163d0e3 100644
--- a/registry/default/example/pulsating-button-demo.tsx
+++ b/registry/default/example/pulsating-button-demo.tsx
@@ -1,4 +1,4 @@
-import PulsatingButton from "@/registry/default/magicui/pulsating-button";
+import { PulsatingButton } from "@/registry/default/magicui/pulsating-button";
export default function PulsatingButtonDemo() {
return <PulsatingButton>Join Affiliate Program</PulsatingButton>;
diff --git a/registry/default/example/ripple-button-demo.tsx b/registry/default/example/ripple-button-demo.tsx
index ec80d3c8..a575c439 100644
--- a/registry/default/example/ripple-button-demo.tsx
+++ b/registry/default/example/ripple-button-demo.tsx
@@ -1,4 +1,4 @@
-import RippleButton from "@/registry/default/magicui/ripple-button";
+import { RippleButton } from "@/registry/default/magicui/ripple-button";
export default function RippleButtonDemo() {
return <RippleButton rippleColor="#ADD8E6">Click me</RippleButton>;
diff --git a/registry/default/example/shimmer-button-demo.tsx b/registry/default/example/shimmer-button-demo.tsx
index 46de4d80..6f0a2045 100644
--- a/registry/default/example/shimmer-button-demo.tsx
+++ b/registry/default/example/shimmer-button-demo.tsx
@@ -1,13 +1,11 @@
-import ShimmerButton from "@/registry/default/magicui/shimmer-button";
+import { ShimmerButton } from "@/registry/default/magicui/shimmer-button";
export default function ShimmerButtonDemo() {
return (
- <div className="z-10 flex min-h-64 items-center justify-center">
- <ShimmerButton className="shadow-2xl">
- <span className="whitespace-pre-wrap text-center text-sm font-medium leading-none tracking-tight text-white dark:from-white dark:to-slate-900/10 lg:text-lg">
- Shimmer Button
- </span>
- </ShimmerButton>
- </div>
+ <ShimmerButton className="shadow-2xl">
+ <span className="whitespace-pre-wrap text-center text-sm font-medium leading-none tracking-tight text-white dark:from-white dark:to-slate-900/10 lg:text-lg">
+ Shimmer Button
+ </span>
+ </ShimmerButton>
);
}
diff --git a/registry/default/example/shiny-button-demo.tsx b/registry/default/example/shiny-button-demo.tsx
index a63f9459..3ce1d866 100644
--- a/registry/default/example/shiny-button-demo.tsx
+++ b/registry/default/example/shiny-button-demo.tsx
@@ -1,4 +1,4 @@
-import ShinyButton from "@/registry/default/magicui/shiny-button";
+import { ShinyButton } from "@/registry/default/magicui/shiny-button";
export default function ShinyButtonDemo() {
return <ShinyButton>Shiny Button</ShinyButton>;
diff --git a/registry/default/magicui/animated-subscribe-button.tsx b/registry/default/magicui/animated-subscribe-button.tsx
index 4531bb24..80e15ecf 100644
--- a/registry/default/magicui/animated-subscribe-button.tsx
+++ b/registry/default/magicui/animated-subscribe-button.tsx
@@ -1,66 +1,98 @@
"use client";
+import { cn } from "@/lib/utils";
+import { HTMLMotionProps } from "motion/react";
import { AnimatePresence, motion } from "motion/react";
import React, { useState } from "react";
-interface AnimatedSubscribeButtonProps {
- buttonColor: string;
- buttonTextColor?: string;
- subscribeStatus: boolean;
- initialText: React.ReactElement | string;
- changeText: React.ReactElement | string;
+interface AnimatedSubscribeButtonProps
+ extends Omit<HTMLMotionProps<"button">, "ref"> {
+ subscribeStatus?: boolean;
+ children: React.ReactNode;
+ className?: string;
}
-export const AnimatedSubscribeButton: React.FC<
+export const AnimatedSubscribeButton = React.forwardRef<
+ HTMLButtonElement,
AnimatedSubscribeButtonProps
-> = ({
- buttonColor,
- subscribeStatus,
- buttonTextColor,
- changeText,
- initialText,
-}) => {
- const [isSubscribed, setIsSubscribed] = useState<boolean>(subscribeStatus);
+>(
+ (
+ { subscribeStatus = false, onClick, className, children, ...props },
+ ref,
+ ) => {
+ const [isSubscribed, setIsSubscribed] = useState<boolean>(subscribeStatus);
- return (
- <AnimatePresence mode="wait">
- {isSubscribed ? (
- <motion.button
- className="relative flex h-10 w-[200px] items-center justify-center overflow-hidden rounded-md bg-white outline outline-1 outline-black"
- onClick={() => setIsSubscribed(false)}
- initial={{ opacity: 0 }}
- animate={{ opacity: 1 }}
- exit={{ opacity: 0 }}
- >
- <motion.span
- key="action"
- className="relative flex h-full w-full items-center justify-center font-semibold"
- initial={{ y: -50 }}
- animate={{ y: 0 }}
- style={{ color: buttonColor }}
+ if (
+ React.Children.count(children) !== 2 ||
+ !React.Children.toArray(children).every(
+ (child) => React.isValidElement(child) && child.type === "span",
+ )
+ ) {
+ throw new Error(
+ "AnimatedSubscribeButton expects two children, both of which must be <span> elements.",
+ );
+ }
+
+ const childrenArray = React.Children.toArray(children);
+ const initialChild = childrenArray[0];
+ const changeChild = childrenArray[1];
+
+ return (
+ <AnimatePresence mode="wait">
+ {isSubscribed ? (
+ <motion.button
+ ref={ref}
+ className={cn(
+ "relative flex h-10 w-fit items-center justify-center overflow-hidden rounded-lg bg-primary px-6 text-primary-foreground",
+ className,
+ )}
+ onClick={(e: React.MouseEvent<HTMLButtonElement>) => {
+ setIsSubscribed(false);
+ onClick?.(e);
+ }}
+ initial={{ opacity: 0 }}
+ animate={{ opacity: 1 }}
+ exit={{ opacity: 0 }}
+ {...props}
>
- {changeText}
- </motion.span>
- </motion.button>
- ) : (
- <motion.button
- className="relative flex h-10 w-[200px] cursor-pointer items-center justify-center rounded-md border-none"
- style={{ backgroundColor: buttonColor, color: buttonTextColor }}
- onClick={() => setIsSubscribed(true)}
- initial={{ opacity: 0 }}
- animate={{ opacity: 1 }}
- exit={{ opacity: 0 }}
- >
- <motion.span
- key="reaction"
- className="relative flex items-center justify-center font-semibold"
- initial={{ x: 0 }}
- exit={{ x: 50, transition: { duration: 0.1 } }}
+ <motion.span
+ key="action"
+ className="relative flex h-full w-full items-center justify-center font-semibold"
+ initial={{ y: -50 }}
+ animate={{ y: 0 }}
+ >
+ {changeChild} {/* Use children for subscribed state */}
+ </motion.span>
+ </motion.button>
+ ) : (
+ <motion.button
+ ref={ref}
+ className={cn(
+ "relative flex h-10 w-fit cursor-pointer items-center justify-center rounded-lg border-none bg-primary px-6 text-primary-foreground",
+ className,
+ )}
+ onClick={(e) => {
+ setIsSubscribed(true);
+ onClick?.(e);
+ }}
+ initial={{ opacity: 0 }}
+ animate={{ opacity: 1 }}
+ exit={{ opacity: 0 }}
+ {...props}
>
- {initialText}
- </motion.span>
- </motion.button>
- )}
- </AnimatePresence>
- );
-};
+ <motion.span
+ key="reaction"
+ className="relative flex items-center justify-center font-semibold"
+ initial={{ x: 0 }}
+ exit={{ x: 50, transition: { duration: 0.1 } }}
+ >
+ {initialChild} {/* Use children for unsubscribed state */}
+ </motion.span>
+ </motion.button>
+ )}
+ </AnimatePresence>
+ );
+ },
+);
+
+AnimatedSubscribeButton.displayName = "AnimatedSubscribeButton";
diff --git a/registry/default/magicui/interactive-hover-button.tsx b/registry/default/magicui/interactive-hover-button.tsx
index 3d4ead8a..e43ccbbe 100644
--- a/registry/default/magicui/interactive-hover-button.tsx
+++ b/registry/default/magicui/interactive-hover-button.tsx
@@ -3,35 +3,33 @@ import { ArrowRight } from "lucide-react";
import { cn } from "@/lib/utils";
interface InteractiveHoverButtonProps
- extends React.ButtonHTMLAttributes<HTMLButtonElement> {
- text?: string;
-}
+ extends React.ButtonHTMLAttributes<HTMLButtonElement> {}
-const InteractiveHoverButton = React.forwardRef<
+export const InteractiveHoverButton = React.forwardRef<
HTMLButtonElement,
InteractiveHoverButtonProps
->(({ text = "Button", className, ...props }, ref) => {
+>(({ children, className, ...props }, ref) => {
return (
<button
ref={ref}
className={cn(
- "group relative w-32 cursor-pointer overflow-hidden rounded-full border bg-background p-2 text-center font-semibold",
+ "group relative w-auto cursor-pointer overflow-hidden rounded-full border bg-background p-2 px-6 text-center font-semibold",
className,
)}
{...props}
>
- <span className="inline-block translate-x-1 transition-all duration-300 group-hover:translate-x-12 group-hover:opacity-0">
- {text}
- </span>
- <div className="absolute top-0 z-10 flex h-full w-full translate-x-12 items-center justify-center gap-2 text-primary-foreground opacity-0 transition-all duration-300 group-hover:-translate-x-1 group-hover:opacity-100">
- <span>{text}</span>
+ <div className="flex items-center gap-2">
+ <div className="h-2 w-2 rounded-full bg-primary transition-all duration-300 group-hover:scale-[100.8]"></div>
+ <span className="inline-block transition-all duration-300 group-hover:translate-x-12 group-hover:opacity-0">
+ {children}
+ </span>
+ </div>
+ <div className="absolute top-0 z-10 flex h-full w-full translate-x-12 items-center justify-center gap-2 text-primary-foreground opacity-0 transition-all duration-300 group-hover:-translate-x-5 group-hover:opacity-100">
+ <span>{children}</span>
<ArrowRight />
</div>
- <div className="absolute left-[20%] top-[40%] h-2 w-2 scale-[1] rounded-full bg-primary transition-all duration-300 group-hover:left-[0%] group-hover:top-[0%] group-hover:h-full group-hover:w-full group-hover:scale-[1.8] group-hover:bg-primary"></div>
</button>
);
});
InteractiveHoverButton.displayName = "InteractiveHoverButton";
-
-export default InteractiveHoverButton;
diff --git a/registry/default/magicui/pulsating-button.tsx b/registry/default/magicui/pulsating-button.tsx
index 3a6e0c29..48546f9f 100644
--- a/registry/default/magicui/pulsating-button.tsx
+++ b/registry/default/magicui/pulsating-button.tsx
@@ -1,7 +1,4 @@
-"use client";
-
import React from "react";
-
import { cn } from "@/lib/utils";
interface PulsatingButtonProps
@@ -10,29 +7,40 @@ interface PulsatingButtonProps
duration?: string;
}
-export default function PulsatingButton({
- className,
- children,
- pulseColor = "#0096ff",
- duration = "1.5s",
- ...props
-}: PulsatingButtonProps) {
- return (
- <button
- className={cn(
- "relative flex cursor-pointer items-center justify-center rounded-lg bg-blue-500 px-4 py-2 text-center text-white dark:bg-blue-500 dark:text-black",
- className,
- )}
- style={
- {
- "--pulse-color": pulseColor,
- "--duration": duration,
- } as React.CSSProperties
- }
- {...props}
- >
- <div className="relative z-10">{children}</div>
- <div className="absolute left-1/2 top-1/2 size-full -translate-x-1/2 -translate-y-1/2 animate-pulse rounded-lg bg-inherit" />
- </button>
- );
-}
+export const PulsatingButton = React.forwardRef<
+ HTMLButtonElement,
+ PulsatingButtonProps
+>(
+ (
+ {
+ className,
+ children,
+ pulseColor = "#0096ff",
+ duration = "1.5s",
+ ...props
+ },
+ ref,
+ ) => {
+ return (
+ <button
+ ref={ref}
+ className={cn(
+ "relative flex cursor-pointer items-center justify-center rounded-lg bg-primary px-4 py-2 text-center text-primary-foreground",
+ className,
+ )}
+ style={
+ {
+ "--pulse-color": pulseColor,
+ "--duration": duration,
+ } as React.CSSProperties
+ }
+ {...props}
+ >
+ <div className="relative z-10">{children}</div>
+ <div className="absolute left-1/2 top-1/2 size-full -translate-x-1/2 -translate-y-1/2 animate-pulse rounded-lg bg-inherit" />
+ </button>
+ );
+ },
+);
+
+PulsatingButton.displayName = "PulsatingButton";
diff --git a/registry/default/magicui/rainbow-button.tsx b/registry/default/magicui/rainbow-button.tsx
index a1f66713..51926cb3 100644
--- a/registry/default/magicui/rainbow-button.tsx
+++ b/registry/default/magicui/rainbow-button.tsx
@@ -1,28 +1,24 @@
import React from "react";
-
import { cn } from "@/lib/utils";
+
interface RainbowButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement> {}
-export function RainbowButton({
- children,
- className,
- ...props
-}: RainbowButtonProps) {
+export const RainbowButton = React.forwardRef<
+ HTMLButtonElement,
+ RainbowButtonProps
+>(({ children, className, ...props }, ref) => {
return (
<button
+ ref={ref}
className={cn(
"group relative inline-flex h-11 animate-rainbow cursor-pointer items-center justify-center rounded-xl border-0 bg-[length:200%] px-8 py-2 font-medium text-primary-foreground transition-colors [background-clip:padding-box,border-box,border-box] [background-origin:border-box] [border:calc(0.08*1rem)_solid_transparent] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
-
// before styles
"before:absolute before:bottom-[-20%] before:left-1/2 before:z-0 before:h-1/5 before:w-3/5 before:-translate-x-1/2 before:animate-rainbow before:bg-[linear-gradient(90deg,hsl(var(--color-1)),hsl(var(--color-5)),hsl(var(--color-3)),hsl(var(--color-4)),hsl(var(--color-2)))] before:[filter:blur(calc(0.8*1rem))]",
-
// light mode colors
"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(var(--color-1)),hsl(var(--color-5)),hsl(var(--color-3)),hsl(var(--color-4)),hsl(var(--color-2)))]",
-
// dark mode colors
"dark: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(var(--color-1)),hsl(var(--color-5)),hsl(var(--color-3)),hsl(var(--color-4)),hsl(var(--color-2)))]",
-
className,
)}
{...props}
@@ -30,4 +26,6 @@ export function RainbowButton({
{children}
</button>
);
-}
+});
+
+RainbowButton.displayName = "RainbowButton";
diff --git a/registry/default/magicui/ripple-button.tsx b/registry/default/magicui/ripple-button.tsx
index f25e56f8..458551d9 100644
--- a/registry/default/magicui/ripple-button.tsx
+++ b/registry/default/magicui/ripple-button.tsx
@@ -9,7 +9,10 @@ interface RippleButtonProps
duration?: string;
}
-const RippleButton = React.forwardRef<HTMLButtonElement, RippleButtonProps>(
+export const RippleButton = React.forwardRef<
+ HTMLButtonElement,
+ RippleButtonProps
+>(
(
{
className,
@@ -86,5 +89,3 @@ const RippleButton = React.forwardRef<HTMLButtonElement, RippleButtonProps>(
);
RippleButton.displayName = "RippleButton";
-
-export default RippleButton;
diff --git a/registry/default/magicui/shimmer-button.tsx b/registry/default/magicui/shimmer-button.tsx
index f6ffe8fb..dc736418 100644
--- a/registry/default/magicui/shimmer-button.tsx
+++ b/registry/default/magicui/shimmer-button.tsx
@@ -13,7 +13,10 @@ export interface ShimmerButtonProps
children?: React.ReactNode;
}
-const ShimmerButton = React.forwardRef<HTMLButtonElement, ShimmerButtonProps>(
+export const ShimmerButton = React.forwardRef<
+ HTMLButtonElement,
+ ShimmerButtonProps
+>(
(
{
shimmerColor = "#ffffff",
@@ -92,5 +95,3 @@ const ShimmerButton = React.forwardRef<HTMLButtonElement, ShimmerButtonProps>(
);
ShimmerButton.displayName = "ShimmerButton";
-
-export default ShimmerButton;
diff --git a/registry/default/magicui/shiny-button.tsx b/registry/default/magicui/shiny-button.tsx
index bd8455f3..9d4ba5ff 100644
--- a/registry/default/magicui/shiny-button.tsx
+++ b/registry/default/magicui/shiny-button.tsx
@@ -29,45 +29,43 @@ const animationProps = {
},
} as AnimationProps;
-interface ShinyButtonProps extends HTMLMotionProps<"button"> {
+interface ShinyButtonProps extends Omit<HTMLMotionProps<"button">, "ref"> {
children: React.ReactNode;
className?: string;
- ref?: React.Ref<HTMLButtonElement>;
}
-const ShinyButton = React.forwardRef<HTMLButtonElement, ShinyButtonProps>(
- ({ children, className, ...props }, ref) => {
- return (
- <motion.button
- ref={ref}
- {...animationProps}
- {...props}
- className={cn(
- "relative rounded-lg px-6 py-2 font-medium backdrop-blur-xl transition-shadow duration-300 ease-in-out hover:shadow dark:bg-[radial-gradient(circle_at_50%_0%,hsl(var(--primary)/10%)_0%,transparent_60%)] dark:hover:shadow-[0_0_20px_hsl(var(--primary)/10%)]",
- className,
- )}
+export const ShinyButton = React.forwardRef<
+ HTMLButtonElement,
+ ShinyButtonProps
+>(({ children, className, ...props }, ref) => {
+ return (
+ <motion.button
+ ref={ref}
+ className={cn(
+ "relative rounded-lg px-6 py-2 font-medium backdrop-blur-xl transition-shadow duration-300 ease-in-out hover:shadow dark:bg-[radial-gradient(circle_at_50%_0%,hsl(var(--primary)/10%)_0%,transparent_60%)] dark:hover:shadow-[0_0_20px_hsl(var(--primary)/10%)]",
+ className,
+ )}
+ {...animationProps}
+ {...props}
+ >
+ <span
+ className="relative block size-full text-sm uppercase tracking-wide text-[rgb(0,0,0,65%)] dark:font-light dark:text-[rgb(255,255,255,90%)]"
+ style={{
+ maskImage:
+ "linear-gradient(-75deg,hsl(var(--primary)) calc(var(--x) + 20%),transparent calc(var(--x) + 30%),hsl(var(--primary)) calc(var(--x) + 100%))",
+ }}
>
- <span
- className="relative block size-full text-sm uppercase tracking-wide text-[rgb(0,0,0,65%)] dark:font-light dark:text-[rgb(255,255,255,90%)]"
- style={{
- maskImage:
- "linear-gradient(-75deg,hsl(var(--primary)) calc(var(--x) + 20%),transparent calc(var(--x) + 30%),hsl(var(--primary)) calc(var(--x) + 100%))",
- }}
- >
- {children}
- </span>
- <span
- style={{
- mask: "linear-gradient(rgb(0,0,0), rgb(0,0,0)) content-box,linear-gradient(rgb(0,0,0), rgb(0,0,0))",
- maskComposite: "exclude",
- }}
- className="absolute inset-0 z-10 block rounded-[inherit] bg-[linear-gradient(-75deg,hsl(var(--primary)/10%)_calc(var(--x)+20%),hsl(var(--primary)/50%)_calc(var(--x)+25%),hsl(var(--primary)/10%)_calc(var(--x)+100%))] p-px"
- ></span>
- </motion.button>
- );
- },
-);
+ {children}
+ </span>
+ <span
+ style={{
+ mask: "linear-gradient(rgb(0,0,0), rgb(0,0,0)) content-box,linear-gradient(rgb(0,0,0), rgb(0,0,0))",
+ maskComposite: "exclude",
+ }}
+ className="absolute inset-0 z-10 block rounded-[inherit] bg-[linear-gradient(-75deg,hsl(var(--primary)/10%)_calc(var(--x)+20%),hsl(var(--primary)/50%)_calc(var(--x)+25%),hsl(var(--primary)/10%)_calc(var(--x)+100%))] p-px"
+ ></span>
+ </motion.button>
+ );
+});
ShinyButton.displayName = "ShinyButton";
-
-export default ShinyButton;