Skip to main content

Installation

npx shadcn-svelte@next add border-beam

Usage

<script lang="ts">
  import { BorderBeam } from "$lib/components/magic/border-beam";
</script>

<div class="relative h-[200px] w-[400px] rounded-lg border">
  <BorderBeam />
  <div class="p-8">Your content here</div>
</div>

Examples

Custom Colors

<div class="relative h-[200px] w-[400px] rounded-lg border">
  <BorderBeam colorFrom="#3b82f6" colorTo="#10b981" />
</div>

Reverse Direction

<div class="relative h-[200px] w-[400px] rounded-lg border">
  <BorderBeam reverse={true} />
</div>

Custom Size and Duration

<div class="relative h-[200px] w-[400px] rounded-lg border">
  <BorderBeam size={100} duration={8} borderWidth={2} />
</div>

Props

size
number
default:"50"
The size of the beam element in pixels.
duration
number
default:"6"
The duration of the animation in seconds.
delay
number
default:"0"
The delay before the animation starts in seconds.
colorFrom
string
default:"#ffaa40"
The starting color of the gradient.
colorTo
string
default:"#9c40ff"
The ending color of the gradient.
borderWidth
number
default:"1"
The width of the border in pixels.
reverse
boolean
default:"false"
Whether to reverse the animation direction.
initialOffset
number
default:"0"
The initial offset position of the beam (0-100).
transition
Transition
Custom motion-sv transition configuration to override default animation settings.
class
string
Additional CSS classes to apply to the beam element.
style
string
Inline styles to apply to the container.

Build docs developers (and LLMs) love