Border Beam
Install: npx shadcn@latest add https://jiguang132.com/r/magic-ui/border-beam.json
Use case
Animate a beam around the edge of a positioned container.
Native props used by the examples
Extracted from all local examples for this entry, grouped by imported module and native owner, including other Magic components used by compound demos. This is not an exhaustive API or a universal host variant. Inspect spread object declarations and the source types/defaults below.
| Owning component prop | Explanation | Example source |
|---|---|---|
BorderBeam.duration (border-beam) | Native animation duration; numeric/CSS units differ by owner, see source defaults. | examples/border-beam-demo.tsx、examples/border-beam-demo-2.tsx、examples/border-beam-demo-3.tsx |
BorderBeam.size (border-beam) | Native beam dimensions; not a universal button size API. | examples/border-beam-demo.tsx、examples/border-beam-demo-2.tsx、examples/border-beam-demo-3.tsx、examples/border-beam-demo-4.tsx |
BorderBeam.className (border-beam) | Classes on this native component; initialize Tailwind and its required CSS first. | examples/border-beam-demo-2.tsx、examples/border-beam-demo-3.tsx、examples/border-beam-demo-4.tsx |
BorderBeam.delay (border-beam) | Native start delay; Motion seconds versus typing/terminal milliseconds must not be mixed. | examples/border-beam-demo-2.tsx |
BorderBeam.borderWidth (border-beam) | Beam border thickness in pixels. | examples/border-beam-demo-2.tsx |
BorderBeam.reverse (border-beam) | Reverse the owning effect's motion direction. | examples/border-beam-demo-3.tsx |
BorderBeam.initialOffset (border-beam) | Initial percentage along the BorderBeam path. | examples/border-beam-demo-4.tsx |
BorderBeam.transition (border-beam) | Native Motion transition object; preserve its own supported type. | examples/border-beam-demo-4.tsx |
Interaction and state checks
- Border Beam Demo —
border-beam-demo - Border Beam Demo —
border-beam-demo-2 - Border Beam Demo 3 —
border-beam-demo-3 - Border Beam Demo 4 —
border-beam-demo-4
These names identify real example entries, not new component props or extra components. Check pointer/keyboard behavior, themes, small screens and failures for the selected example. Decorative effects must not invent disabled/error/submission states. Complete example installation includes the actual dependency closure.
Business integration boundary
Mount inside a relative container with matching corner radius; size/duration/delay belong to the effect, not to the host card.
Host and motion setup
Initialize Tailwind CSS v4, semantic CSS variables and the dark variant; import the independent local Registry namespace. Reuse an existing next-themes Provider without substituting JGuang UI/Base UI/HeroUI APIs. Mount effects in view and unmount offscreen; provide static alternatives for unavailable Canvas/WebGL or failed remote media. Respect prefers-reduced-motion and verify timer/RAF/observer/listener cleanup: stopping CSS alone does not prove the engine stopped. Examples provide no backend, login, payment or real AI stream. This practical guide is bilingual; detailed upstream references and demo text retain their original language.
Available examples
border-beam-demo, border-beam-demo-2, border-beam-demo-3, border-beam-demo-4
Demo state and mock data do not provide a backend service. Inspect the component props before wiring real data.
Installation
<Tabs defaultValue="cli"> <TabsList> <TabsTrigger value="cli">CLI</TabsTrigger> <TabsTrigger value="manual">Manual</TabsTrigger> </TabsList> <TabsContent value="cli">npx shadcn@latest add @magicui/border-beam
</TabsContent>
<TabsContent value="manual">
<Steps>
<Step>Copy and paste the following code into your project.</Step>
</Steps> </TabsContent> </Tabs>Examples
2 Border Beams
Reverse
Spring Animation
Usage
import { BorderBeam } from "@/components/ui/border-beam"
<div className="relative h-[500px] w-full overflow-hidden">
<BorderBeam />
</div>
Props
Border Beam
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Custom class to apply to the component |
size | number | 50 | Size of the beam |
duration | number | 6 | Duration of the animation in seconds |
delay | number | 0 | Delay before the animation starts |
colorFrom | string | #ffaa40 | Start color of the beam gradient |
colorTo | string | #9c40ff | End color of the beam gradient |
transition | Transition | - | Custom motion transition configuration |
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 |
Complete example installation
The component command installs the component. Each example command also includes its actual imported components, native support UI, utilities and pinned dependencies. Helpers are not additional catalog components.
Border Beam Demo
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/border-beam/border-beam-demo.json
Default import: @/components/magicui/examples/border-beam-demo
Dependencies: @radix-ui/react-label@2.1.11, @radix-ui/react-slot@1.3.0, class-variance-authority@0.7.1, clsx@2.1.1, motion@12.42.2, tailwind-merge@3.6.0
Border Beam Demo
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/border-beam/border-beam-demo-2.json
Default import: @/components/magicui/examples/border-beam-demo-2
Dependencies: @radix-ui/react-slot@1.3.0, class-variance-authority@0.7.1, clsx@2.1.1, lucide-react@1.24.0, motion@12.42.2, tailwind-merge@3.6.0
Border Beam Demo 3
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/border-beam/border-beam-demo-3.json
Default import: @/components/magicui/examples/border-beam-demo-3
Dependencies: @radix-ui/react-label@2.1.11, @radix-ui/react-slot@1.3.0, class-variance-authority@0.7.1, clsx@2.1.1, motion@12.42.2, tailwind-merge@3.6.0
Border Beam Demo 4
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/border-beam/border-beam-demo-4.json
Default import: @/components/magicui/examples/border-beam-demo-4
Dependencies: @radix-ui/react-slot@1.3.0, class-variance-authority@0.7.1, clsx@2.1.1, motion@12.42.2, tailwind-merge@3.6.0
Minimal usage and theme
import Demo from '@/components/magicui/examples/border-beam-demo';
import { ThemeProvider } from 'next-themes';
export default function Example() {
return <ThemeProvider attribute="class" defaultTheme="system" enableSystem><Demo /></ThemeProvider>;
}
Initialize Tailwind CSS v4, semantic color variables and the dark variant first. Reuse an existing next-themes provider rather than nesting another. Next Link examples require a Next.js environment; in static Vite projects adapt the demo links to your router without changing the native component API. Some media and tweets require network access. Examples do not supply authentication or backend services.
Source-backed parameter reference
Implementation signatures and types are generated from the pinned local source. Optional props, native inherited types, union branches and never exclusions are preserved. A forwardRef implementation's ref is a React reference, not an additional business prop.
BorderBeam({
className,
size = 50,
delay = 0,
duration = 6,
colorFrom = "#ffaa40",
colorTo = "#9c40ff",
transition,
style,
reverse = false,
initialOffset = 0,
borderWidth = 1,
}: BorderBeamProps)
interface BorderBeamProps {
/**
* The size of the border beam.
*/
size?: number
/**
* The duration of the border beam.
*/
duration?: number
/**
* The delay of the border beam.
*/
delay?: number
/**
* The color of the border beam from.
*/
colorFrom?: string
/**
* The color of the border beam to.
*/
colorTo?: string
/**
* The motion transition of the border beam.
*/
transition?: Transition
/**
* The class name of the border beam.
*/
className?: string
/**
* The style of the border beam.
*/
style?: React.CSSProperties
/**
* Whether to reverse the animation direction.
*/
reverse?: boolean
/**
* The initial offset position (0-100).
*/
initialOffset?: number
/**
* The border width of the beam.
*/
borderWidth?: number
}
Destructuring defaults in source
Only defaults written directly in parameter/props destructuring are listed. Conditional expressions, runtime theme and computed values require source inspection; this is not an exhaustive behavior-default list.
// BorderBeam
size = 50
// BorderBeam
delay = 0
// BorderBeam
duration = 6
// BorderBeam
colorFrom = "#ffaa40"
// BorderBeam
colorTo = "#9c40ff"
// BorderBeam
reverse = false
// BorderBeam
initialOffset = 0
// BorderBeam
borderWidth = 1
Native and external types
External types remain defined by React or native dependencies, not manually expanded into guessed props. The installed version's TypeScript definitions are authoritative.
Transition
React.CSSProperties