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 'borderWidth' prop to Border Beam (#687)

Rishit Gupta5de442ef57b9
diff --git a/content/docs/components/border-beam.mdx b/content/docs/components/border-beam.mdx
index 952aed3d..c5f06968 100644
--- a/content/docs/components/border-beam.mdx
+++ b/content/docs/components/border-beam.mdx
@@ -81,3 +81,4 @@ import { BorderBeam } from "@/components/magicui/border-beam";
| `style` | `React.CSSProperties` | `-` | Custom CSS styles to apply |
| `reverse` | `boolean` | `false` | Whether to reverse animation direction |
| `initialOffset` | `number` | `0` | Initial offset position (0-100) |
+| `borderWidth` | `number` | `1` | Border width of the beam |
diff --git a/registry/example/border-beam-demo-2.tsx b/registry/example/border-beam-demo-2.tsx
index 83727491..cb265639 100644
--- a/registry/example/border-beam-demo-2.tsx
+++ b/registry/example/border-beam-demo-2.tsx
@@ -49,6 +49,7 @@ export default function MusicPlayer() {
duration={6}
delay={3}
size={400}
+ borderWidth={2}
className="from-transparent via-blue-500 to-transparent"
/>
</Card>
diff --git a/registry/magicui/border-beam.tsx b/registry/magicui/border-beam.tsx
index 1ddcd5df..c9ca066f 100644
--- a/registry/magicui/border-beam.tsx
+++ b/registry/magicui/border-beam.tsx
@@ -44,6 +44,10 @@ interface BorderBeamProps {
* The initial offset position (0-100).
*/
initialOffset?: number;
+ /**
+ * The border width of the beam.
+ */
+ borderWidth?: number;
}
export const BorderBeam = ({
@@ -57,9 +61,15 @@ export const BorderBeam = ({
style,
reverse = false,
initialOffset = 0,
+ borderWidth = 1,
}: BorderBeamProps) => {
return (
- <div className="pointer-events-none absolute inset-0 rounded-[inherit] border border-transparent [mask-clip:padding-box,border-box] [mask-composite:intersect] [mask-image:linear-gradient(transparent,transparent),linear-gradient(#000,#000)]">
+ <div
+ className="pointer-events-none absolute inset-0 rounded-[inherit] border-transparent [mask-clip:padding-box,border-box] [mask-composite:intersect] [mask-image:linear-gradient(transparent,transparent),linear-gradient(#000,#000)] border-(length:--border-beam-width)"
+ style={{
+ "--border-beam-width": `${borderWidth}px`,
+ } as React.CSSProperties}
+ >
<motion.div
className={cn(
"absolute aspect-square",