Border Beam
magicui/border-beamFreeComponent
An animated beam of light which travels along the border of its container.
Live preview
live · rendered by the registry
Rendered by magicui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://magicui.design/r/border-beam.jsonSource
1"use client"23import { motion, type MotionStyle, type Transition } from "motion/react"45import { cn } from "@/lib/utils"67interface BorderBeamProps {8 /**9 * The size of the border beam.10 */11 size?: number12 /**13 * The duration of the border beam.14 */15 duration?: number16 /**17 * The delay of the border beam.18 */19 delay?: number20 /**21 * The color of the border beam from.22 */23 colorFrom?: string24 /**25 * The color of the border beam to.26 */27 colorTo?: string28 /**29 * The motion transition of the border beam.30 */31 transition?: Transition32 /**33 * The class name of the border beam.34 */35 className?: string36 /**37 * The style of the border beam.38 */39 style?: React.CSSProperties40 /**41 * Whether to reverse the animation direction.42 */43 reverse?: boolean44 /**45 * The initial offset position (0-100).46 */47 initialOffset?: number48 /**49 * The border width of the beam.50 */51 borderWidth?: number52}5354export const BorderBeam = ({55 className,56 size = 50,57 delay = 0,58 duration = 6,59 colorFrom = "#ffaa40",60 colorTo = "#9c40ff",61 transition,62 style,63 reverse = false,64 initialOffset = 0,65 borderWidth = 1,66}: BorderBeamProps) => {67 return (68 <div69 className="pointer-events-none absolute inset-0 rounded-[inherit] border-(length:--border-beam-width) border-transparent mask-[linear-gradient(transparent,transparent),linear-gradient(#000,#000)] mask-intersect [mask-clip:padding-box,border-box]"70 style={71 {72 "--border-beam-width": `${borderWidth}px`,73 } as React.CSSProperties74 }75 >76 <motion.div77 className={cn(78 "absolute aspect-square",79 "bg-linear-to-l from-(--color-from) via-(--color-to) to-transparent",80 className81 )}82 style={83 {84 width: size,85 offsetPath: `rect(0 auto auto 0 round ${size}px)`,86 "--color-from": colorFrom,87 "--color-to": colorTo,88 ...style,89 } as MotionStyle90 }91 initial={{ offsetDistance: `${initialOffset}%` }}92 animate={{93 offsetDistance: reverse94 ? [`${100 - initialOffset}%`, `${-initialOffset}%`]95 : [`${initialOffset}%`, `${100 + initialOffset}%`],96 }}97 transition={{98 repeat: Infinity,99 ease: "linear",100 duration,101 delay: -delay,102 ...transition,103 }}104 />105 </div>106 )107}
What it pulls in
npm packages
Files it writes
More from magicui
All 247 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Androidandroid | magicui | Components | Free | no deps | |
| Animated Beamanimated-beam | magicui | Components | Free | 1 dep | |
| Animated Circular Progress Baranimated-circular-progress-bar | magicui | Components | Free | no deps | |
| Animated Gradient Textanimated-gradient-text | magicui | Components | Free | no deps | |
| Animated Grid Patternanimated-grid-pattern | magicui | Components | Free | 1 dep | |
| Animated Listanimated-list | magicui | Components | Free | 1 dep | |
| Animated Shiny Textanimated-shiny-text | magicui | Components | Free | no deps | |
| Theme Toggleranimated-theme-toggler | magicui | Components | Free | 1 dep |
