Skip to content

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

fix: update shine border api and demos (#574)

Dillion Vermaec53cb6e53b9
diff --git a/content/docs/components/shine-border.mdx b/content/docs/components/shine-border.mdx
index ecaffc75..e27d549d 100644
--- a/content/docs/components/shine-border.mdx
+++ b/content/docs/components/shine-border.mdx
@@ -76,18 +76,24 @@ module.exports = {
<ComponentPreview name="shine-border-demo-2" />
-## Props
+## Usage
-| Prop | Type | Default | Description |
-| -------------- | ----------- | --------- | ------------------------------------------------------------------- |
-| `className` | `string` | `-` | The class name to be applied to the component. |
-| `duration` | `number` | `14` | Defines the animation duration to be applied on the shining border. |
-| `color` | `string` | `#FFFFFF` | Defines the color of the border. |
-| `borderRadius` | `number` | `8` | Defines the radius of the border. |
-| `borderWidth` | `number` | `1` | Defines the width of the border. |
-| `children` | `ReactNode` | `{}` | Contains react node elements. |
+```tsx
+import { ShineBorder } from "@/registry/magicui/shine-border";
+```
-## Credits
+```tsx
+<div className="relative overflow-hidden">
+ <ShineBorder />
+</div>
+```
+
+## Props
-- Credits to [Matthew Goshman](https://codepen.io/matthewgoshman/pen/bGMpKZy) for this fantastic component.
-- Credits to [Anu Adebayo](https://twitter.com/unnamedcodes) for improving and customizing the component.
+| Prop | Type | Default | Description |
+| ------------- | --------------------- | ----------- | ------------------------------------------------------------------- |
+| `className` | `string` | `-` | The class name to be applied to the component. |
+| `duration` | `number` | `14` | Defines the animation duration to be applied on the shining border. |
+| `shineColor` | `string \| string[]` | `"#000000"` | Color of the border, can be a single color or an array of colors. |
+| `borderWidth` | `number` | `1` | Width of the border in pixels. |
+| `style` | `React.CSSProperties` | `-` | Additional styles to be applied to the component. |
diff --git a/public/r/shine-border-demo-2.json b/public/r/shine-border-demo-2.json
index 85f40fe6..43455616 100644
--- a/public/r/shine-border-demo-2.json
+++ b/public/r/shine-border-demo-2.json
@@ -10,7 +10,7 @@
"files": [
{
"path": "registry/example/shine-border-demo-2.tsx",
- "content": "\"use client\";\n\nimport { useTheme } from \"next-themes\";\n\nimport { ShineBorder } from \"@/components/magicui/shine-border\";\n\nexport default function ShineBorderDemo() {\n const theme = useTheme();\n return (\n <ShineBorder\n className=\"relative size-48 rounded-lg\"\n color={theme.theme === \"dark\" ? \"white\" : \"black\"}\n />\n );\n}\n",
+ "content": "\"use client\";\n\nimport { Button } from \"@/components/ui/button\";\nimport {\n Card,\n CardContent,\n CardDescription,\n CardFooter,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\";\nimport { Input } from \"@/components/ui/input\";\nimport { Label } from \"@/components/ui/label\";\nimport { ShineBorder } from \"@/components/magicui/shine-border\";\nimport { useTheme } from \"next-themes\";\n\nexport default function ShineBorderDemo2() {\n const theme = useTheme();\n return (\n <Card className=\"relative overflow-hidden\">\n <ShineBorder shineColor={theme.theme === \"dark\" ? \"white\" : \"black\"} />\n <CardHeader>\n <CardTitle>Login</CardTitle>\n <CardDescription>\n Enter your credentials to access your account\n </CardDescription>\n </CardHeader>\n <CardContent>\n <form>\n <div className=\"grid gap-4\">\n <div className=\"grid gap-2\">\n <Label htmlFor=\"email\">Email</Label>\n <Input id=\"email\" type=\"email\" placeholder=\"[email protected]\" />\n </div>\n <div className=\"grid gap-2\">\n <Label htmlFor=\"password\">Password</Label>\n <Input id=\"password\" type=\"password\" />\n </div>\n </div>\n </form>\n </CardContent>\n <CardFooter>\n <Button className=\"w-full\">Sign In</Button>\n </CardFooter>\n </Card>\n );\n}\n",
"type": "registry:example",
"target": "components/shine-border-demo-2.tsx"
}
diff --git a/public/r/shine-border-demo.json b/public/r/shine-border-demo.json
index 7c32620b..86714e84 100644
--- a/public/r/shine-border-demo.json
+++ b/public/r/shine-border-demo.json
@@ -10,7 +10,7 @@
"files": [
{
"path": "registry/example/shine-border-demo.tsx",
- "content": "import { ShineBorder } from \"@/components/magicui/shine-border\";\n\nexport default function ShineBorderDemo() {\n return (\n <ShineBorder\n className=\"relative size-48 rounded-lg\"\n color={[\"#A07CFE\", \"#FE8FB5\", \"#FFBE7B\"]}\n />\n );\n}\n",
+ "content": "import { Button } from \"@/components/ui/button\";\nimport {\n Card,\n CardContent,\n CardDescription,\n CardFooter,\n CardHeader,\n CardTitle,\n} from \"@/components/ui/card\";\nimport { Input } from \"@/components/ui/input\";\nimport { Label } from \"@/components/ui/label\";\nimport { ShineBorder } from \"@/components/magicui/shine-border\";\n\nexport default function ShineBorderDemo() {\n return (\n <Card className=\"relative overflow-hidden\">\n <ShineBorder shineColor={[\"#A07CFE\", \"#FE8FB5\", \"#FFBE7B\"]} />\n <CardHeader>\n <CardTitle>Login</CardTitle>\n <CardDescription>\n Enter your credentials to access your account\n </CardDescription>\n </CardHeader>\n <CardContent>\n <form>\n <div className=\"grid gap-4\">\n <div className=\"grid gap-2\">\n <Label htmlFor=\"email\">Email</Label>\n <Input id=\"email\" type=\"email\" placeholder=\"[email protected]\" />\n </div>\n <div className=\"grid gap-2\">\n <Label htmlFor=\"password\">Password</Label>\n <Input id=\"password\" type=\"password\" />\n </div>\n </div>\n </form>\n </CardContent>\n <CardFooter>\n <Button className=\"w-full\">Sign In</Button>\n </CardFooter>\n </Card>\n );\n}\n",
"type": "registry:example",
"target": "components/shine-border-demo.tsx"
}
diff --git a/public/r/shine-border.json b/public/r/shine-border.json
index 64d1cadb..8785fbe7 100644
--- a/public/r/shine-border.json
+++ b/public/r/shine-border.json
@@ -7,7 +7,7 @@
"files": [
{
"path": "registry/magicui/shine-border.tsx",
- "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\n\ntype TColorProp = string | string[];\n\ninterface ShineBorderProps {\n borderRadius?: number;\n borderWidth?: number;\n duration?: number;\n color?: TColorProp;\n className?: string;\n children?: React.ReactNode;\n}\n\n/**\n * @name Shine Border\n * @description It is an animated background border effect component with easy to use and configurable props.\n * @param borderRadius defines the radius of the border.\n * @param borderWidth defines the width of the border.\n * @param duration defines the animation duration to be applied on the shining border\n * @param color a string or string array to define border color.\n * @param className defines the class name to be applied to the component\n * @param children contains react node elements.\n */\nexport function ShineBorder({\n borderRadius = 8,\n borderWidth = 1,\n duration = 14,\n color = \"#000000\",\n className,\n children,\n}: ShineBorderProps) {\n return (\n <div\n style={\n {\n \"--border-radius\": `${borderRadius}px`,\n } as React.CSSProperties\n }\n className={cn(\n \"relative min-h-[60px] w-fit min-w-[300px] place-items-center rounded-[--border-radius] p-3 bg-background border\",\n className,\n )}\n >\n <div\n style={\n {\n \"--border-width\": `${borderWidth}px`,\n \"--border-radius\": `${borderRadius}px`,\n \"--duration\": `${duration}s`,\n \"--mask-linear-gradient\": `linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)`,\n \"--background-radial-gradient\": `radial-gradient(transparent,transparent, ${color instanceof Array ? color.join(\",\") : color},transparent,transparent)`,\n } as React.CSSProperties\n }\n className={`before:bg-shine-size pointer-events-none before:absolute before:inset-0 before:size-full before:rounded-[--border-radius] before:p-[--border-width] before:will-change-[background-position] before:content-[\"\"] before:![-webkit-mask-composite:xor] before:![mask-composite:exclude] before:[background-image:--background-radial-gradient] before:[background-size:300%_300%] before:[mask:--mask-linear-gradient] motion-safe:before:animate-shine`}\n ></div>\n {children}\n </div>\n );\n}\n",
+ "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport * as React from \"react\";\n\ninterface ShineBorderProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Width of the border in pixels\n * @default 1\n */\n borderWidth?: number;\n /**\n * Duration of the animation in seconds\n * @default 14\n */\n duration?: number;\n /**\n * Color of the border, can be a single color or an array of colors\n * @default \"#000000\"\n */\n shineColor?: string | string[];\n}\n\n/**\n * Shine Border\n *\n * An animated background border effect component with configurable properties.\n */\nexport function ShineBorder({\n borderWidth = 1,\n duration = 14,\n shineColor = \"#000000\",\n className,\n style,\n ...props\n}: ShineBorderProps) {\n return (\n <div\n style={\n {\n \"--border-width\": `${borderWidth}px`,\n \"--duration\": `${duration}s`,\n \"--mask-linear-gradient\": `linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)`,\n \"--background-radial-gradient\": `radial-gradient(transparent,transparent, ${Array.isArray(shineColor) ? shineColor.join(\",\") : shineColor},transparent,transparent)`,\n backgroundImage: \"var(--background-radial-gradient)\",\n backgroundSize: \"300% 300%\",\n mask: \"var(--mask-linear-gradient)\",\n WebkitMaskComposite: \"xor\",\n maskComposite: \"exclude\",\n ...style,\n } as React.CSSProperties\n }\n className={cn(\n \"pointer-events-none absolute inset-0 size-full rounded-[inherit] p-[--border-width] will-change-[background-position] motion-safe:animate-shine\",\n className,\n )}\n {...props}\n />\n );\n}\n",
"type": "registry:ui",
"target": "components/magicui/shine-border.tsx"
}
diff --git a/registry/example/shine-border-demo-2.tsx b/registry/example/shine-border-demo-2.tsx
index eaf05a88..f98afdb3 100644
--- a/registry/example/shine-border-demo-2.tsx
+++ b/registry/example/shine-border-demo-2.tsx
@@ -1,15 +1,47 @@
"use client";
-import { useTheme } from "next-themes";
-
+import { Button } from "@/components/ui/button";
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardFooter,
+ CardHeader,
+ CardTitle,
+} from "@/components/ui/card";
+import { Input } from "@/components/ui/input";
+import { Label } from "@/components/ui/label";
import { ShineBorder } from "@/registry/magicui/shine-border";
+import { useTheme } from "next-themes";
-export default function ShineBorderDemo() {
+export default function ShineBorderDemo2() {
const theme = useTheme();
return (
- <ShineBorder
- className="relative size-48 rounded-lg"
- color={theme.theme === "dark" ? "white" : "black"}
- />
+ <Card className="relative overflow-hidden">
+ <ShineBorder shineColor={theme.theme === "dark" ? "white" : "black"} />
+ <CardHeader>
+ <CardTitle>Login</CardTitle>
+ <CardDescription>
+ Enter your credentials to access your account
+ </CardDescription>
+ </CardHeader>
+ <CardContent>
+ <form>
+ <div className="grid gap-4">
+ <div className="grid gap-2">
+ <Label htmlFor="email">Email</Label>
+ <Input id="email" type="email" placeholder="[email protected]" />
+ </div>
+ <div className="grid gap-2">
+ <Label htmlFor="password">Password</Label>
+ <Input id="password" type="password" />
+ </div>
+ </div>
+ </form>
+ </CardContent>
+ <CardFooter>
+ <Button className="w-full">Sign In</Button>
+ </CardFooter>
+ </Card>
);
}
diff --git a/registry/example/shine-border-demo.tsx b/registry/example/shine-border-demo.tsx
index ece90f3c..63032a87 100644
--- a/registry/example/shine-border-demo.tsx
+++ b/registry/example/shine-border-demo.tsx
@@ -1,10 +1,43 @@
+import { Button } from "@/components/ui/button";
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardFooter,
+ CardHeader,
+ CardTitle,
+} from "@/components/ui/card";
+import { Input } from "@/components/ui/input";
+import { Label } from "@/components/ui/label";
import { ShineBorder } from "@/registry/magicui/shine-border";
export default function ShineBorderDemo() {
return (
- <ShineBorder
- className="relative size-48 rounded-lg"
- color={["#A07CFE", "#FE8FB5", "#FFBE7B"]}
- />
+ <Card className="relative overflow-hidden">
+ <ShineBorder shineColor={["#A07CFE", "#FE8FB5", "#FFBE7B"]} />
+ <CardHeader>
+ <CardTitle>Login</CardTitle>
+ <CardDescription>
+ Enter your credentials to access your account
+ </CardDescription>
+ </CardHeader>
+ <CardContent>
+ <form>
+ <div className="grid gap-4">
+ <div className="grid gap-2">
+ <Label htmlFor="email">Email</Label>
+ <Input id="email" type="email" placeholder="[email protected]" />
+ </div>
+ <div className="grid gap-2">
+ <Label htmlFor="password">Password</Label>
+ <Input id="password" type="password" />
+ </div>
+ </div>
+ </form>
+ </CardContent>
+ <CardFooter>
+ <Button className="w-full">Sign In</Button>
+ </CardFooter>
+ </Card>
);
}
diff --git a/registry/magicui/shine-border.tsx b/registry/magicui/shine-border.tsx
index e3887ac2..cb17926f 100644
--- a/registry/magicui/shine-border.tsx
+++ b/registry/magicui/shine-border.tsx
@@ -1,61 +1,60 @@
"use client";
import { cn } from "@/lib/utils";
+import * as React from "react";
-type TColorProp = string | string[];
-
-interface ShineBorderProps {
- borderRadius?: number;
+interface ShineBorderProps extends React.HTMLAttributes<HTMLDivElement> {
+ /**
+ * Width of the border in pixels
+ * @default 1
+ */
borderWidth?: number;
+ /**
+ * Duration of the animation in seconds
+ * @default 14
+ */
duration?: number;
- color?: TColorProp;
- className?: string;
- children?: React.ReactNode;
+ /**
+ * Color of the border, can be a single color or an array of colors
+ * @default "#000000"
+ */
+ shineColor?: string | string[];
}
/**
- * @name Shine Border
- * @description It is an animated background border effect component with easy to use and configurable props.
- * @param borderRadius defines the radius of the border.
- * @param borderWidth defines the width of the border.
- * @param duration defines the animation duration to be applied on the shining border
- * @param color a string or string array to define border color.
- * @param className defines the class name to be applied to the component
- * @param children contains react node elements.
+ * Shine Border
+ *
+ * An animated background border effect component with configurable properties.
*/
export function ShineBorder({
- borderRadius = 8,
borderWidth = 1,
duration = 14,
- color = "#000000",
+ shineColor = "#000000",
className,
- children,
+ style,
+ ...props
}: ShineBorderProps) {
return (
<div
style={
{
- "--border-radius": `${borderRadius}px`,
+ "--border-width": `${borderWidth}px`,
+ "--duration": `${duration}s`,
+ "--mask-linear-gradient": `linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)`,
+ "--background-radial-gradient": `radial-gradient(transparent,transparent, ${Array.isArray(shineColor) ? shineColor.join(",") : shineColor},transparent,transparent)`,
+ backgroundImage: "var(--background-radial-gradient)",
+ backgroundSize: "300% 300%",
+ mask: "var(--mask-linear-gradient)",
+ WebkitMaskComposite: "xor",
+ maskComposite: "exclude",
+ ...style,
} as React.CSSProperties
}
className={cn(
- "relative min-h-[60px] w-fit min-w-[300px] place-items-center rounded-[--border-radius] p-3 bg-background border",
+ "pointer-events-none absolute inset-0 size-full rounded-[inherit] p-[--border-width] will-change-[background-position] motion-safe:animate-shine",
className,
)}
- >
- <div
- style={
- {
- "--border-width": `${borderWidth}px`,
- "--border-radius": `${borderRadius}px`,
- "--duration": `${duration}s`,
- "--mask-linear-gradient": `linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)`,
- "--background-radial-gradient": `radial-gradient(transparent,transparent, ${color instanceof Array ? color.join(",") : color},transparent,transparent)`,
- } as React.CSSProperties
- }
- className={`before:bg-shine-size pointer-events-none before:absolute before:inset-0 before:size-full before:rounded-[--border-radius] before:p-[--border-width] before:will-change-[background-position] before:content-[""] before:![-webkit-mask-composite:xor] before:![mask-composite:exclude] before:[background-image:--background-radial-gradient] before:[background-size:300%_300%] before:[mask:--mask-linear-gradient] motion-safe:before:animate-shine`}
- ></div>
- {children}
- </div>
+ {...props}
+ />
);
}