Skip to content

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

feat: Add Shiny Button Component (#58)

Luis Tenorio8062402255a2
diff --git a/config/docs.ts b/config/docs.ts
index b0b6cb39..9c21e829 100644
--- a/config/docs.ts
+++ b/config/docs.ts
@@ -235,6 +235,12 @@ export const docsConfig: DocsConfig = {
href: `/docs/components/shimmer-button`,
items: [],
},
+ {
+ title: "Shiny Button",
+ href: `/docs/components/shiny-button`,
+ items: [],
+ label: "New",
+ },
],
},
{
diff --git a/content/docs/components/shiny-button.mdx b/content/docs/components/shiny-button.mdx
new file mode 100644
index 00000000..c6ea98d5
--- /dev/null
+++ b/content/docs/components/shiny-button.mdx
@@ -0,0 +1,33 @@
+---
+title: Shiny Button
+date: 2024-05-24
+description: A shiny button component with dynamic styles in the dark mode or light mode.
+author: luis-codex
+published: true
+---
+
+<ComponentPreview name="shiny-button-demo" />
+
+<Steps>
+
+### Installation
+
+Copy and paste the following code into your project.
+
+```text
+components/magicui/shiny-button.tsx
+```
+
+<ComponentSource name="shiny-button" />
+
+</Steps>
+
+## Props
+
+| Prop | Type | Description | Default |
+| ---- | ------ | ------------------- | -------------- |
+| text | string | The text to display | "shiny button" |
+
+## Credits
+
+- Credit to [@luis-code](https://luis-code.vercel.app/)
diff --git a/registry/components/example/shiny-button-demo.tsx b/registry/components/example/shiny-button-demo.tsx
new file mode 100644
index 00000000..b4377e16
--- /dev/null
+++ b/registry/components/example/shiny-button-demo.tsx
@@ -0,0 +1,5 @@
+import ShinyButton from "@/registry/components/magicui/shiny-button";
+
+export default function ShinyButtonDemo() {
+ return <ShinyButton text="Shiny Button" />;
+}
diff --git a/registry/components/magicui/shiny-button.tsx b/registry/components/magicui/shiny-button.tsx
new file mode 100644
index 00000000..b7ada9cf
--- /dev/null
+++ b/registry/components/magicui/shiny-button.tsx
@@ -0,0 +1,51 @@
+"use client";
+import { type AnimationProps, motion } from "framer-motion";
+
+const animationProps = {
+ initial: { "--x": "100%", scale: 0.8 },
+ animate: { "--x": "-100%", scale: 1 },
+ whileTap: { scale: 0.95 },
+ transition: {
+ repeat: Infinity,
+ repeatType: "loop",
+ repeatDelay: 1,
+ type: "spring",
+ stiffness: 20,
+ damping: 15,
+ mass: 2,
+ scale: {
+ type: "spring",
+ stiffness: 200,
+ damping: 5,
+ mass: 0.5,
+ },
+ },
+} as AnimationProps;
+
+const ShinyButton = ({ text = "shiny-button" }) => {
+ return (
+ <motion.button
+ {...animationProps}
+ className="relative rounded-lg px-6 py-2 font-medium backdrop-blur-xl transition-[box-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%)]"
+ >
+ <span
+ className="relative block h-full w-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%))",
+ }}
+ >
+ {text}
+ </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>
+ );
+};
+
+export default ShinyButton;
diff --git a/registry/index.tsx b/registry/index.tsx
index fd1319b9..b69c7e41 100644
--- a/registry/index.tsx
+++ b/registry/index.tsx
@@ -207,6 +207,11 @@ const ui: Registry = {
type: "components:ui",
files: ["registry/components/magicui/fade-text.tsx"],
},
+ "shiny-button": {
+ name: "shiny-button",
+ type: "components:ui",
+ files: ["registry/components/magicui/shiny-button.tsx"],
+ },
};
const example: Registry = {
@@ -734,6 +739,14 @@ const example: Registry = {
() => import("@/registry/components/example/fade-text-demo"),
),
},
+ "shiny-button-demo": {
+ name: "shiny-button-demo",
+ type: "components:example",
+ files: ["registry/components/example/shiny-button-demo.tsx"],
+ component: React.lazy(
+ () => import("@/registry/components/example/shiny-button-demo"),
+ ),
+ },
};
export const registry: Registry = {
...ui,