Border beam
A soft glow that rides the border of any card, button or input.
Working…
- Generate colour palettes
- Recommend font pairings
- Create layout templates
- Build section engine
Deploy preview Ready in 14s Live
Playground
<script>
import { BorderBeam } from 'runeglow/border-beam';
</script>
<BorderBeam>
<Card>Content</Card>
</BorderBeam>Install
pnpm add runeglow Or copy just this library’s source into your project, with the shadcn-svelte CLI:
npx shadcn-svelte@latest add https://runeglow.dev/r/border-beam.json import { BorderBeam } from 'runeglow/border-beam';Usage
Wrap the element that should glow. The component adds one wrapper and three decorative layers that ignore pointer events, so your element keeps its markup.
<script>
import { BorderBeam } from 'runeglow/border-beam';
</script>
<BorderBeam>
<div class="card">Your content here</div>
</BorderBeam>active fades the beam in and out, and tells you when each fade has
finished.
<script>
import { BorderBeam } from 'runeglow/border-beam';
let thinking = $state(false);
</script>
<BorderBeam
size="pulse-inner"
active={thinking}
onDeactivate={() => console.log('faded out')}
>
<textarea placeholder="Ask anything…"></textarea>
</BorderBeam>CSS variables tune single layers, and css appends your own rules to
the generated sheet.
<BorderBeam
size="line"
style="--beam-hue-base: 40deg; --beam-spike-mul: 1.4"
css={`
[data-beam="{id}"] [data-beam-bloom] { mix-blend-mode: screen; }
`}
>
<SearchBar />
</BorderBeam>Props
Prop Type Default Description
children Snippet – The element to wrap. Its border radius is detected automatically.size 'md' | 'sm' | 'line' | 'pulse-inner' | 'pulse-outside' 'md' The beam type. md, sm and line travel; the pulse types breathe in place.colorVariant 'colorful' | 'mono' | 'ocean' | 'sunset' | 'forest' | 'candy' | 'ice' | 'gold' 'colorful' The palette.theme 'dark' | 'light' | 'auto' 'dark' Tunes the glow for the background it sits on. auto follows prefers-color-scheme.active boolean true Fades the effect in and out.strength number 1 Opacity of the effect layers, 0 to 1. The wrapped content is untouched.duration number 1.96 / 3.1 / 2.3 Seconds per cycle. The default depends on the type: rotate, line, pulse.borderRadius number auto Corner radius in pixels. Omit it to read the radius of the first child.brightness number per type Brightness multiplier for the glow.saturation number per type Saturation multiplier for the glow.glowSize number 1 Scales the blur radius of every glow layer, keeping their proportions.hueRange number 30 Degrees of hue drift over a cycle on the rotate types. line caps it at 13; the pulse types always rotate the full circle.staticColors boolean false Turns the hue drift off. mono is always static.css string – Extra CSS appended to the generated sheet. {id} is replaced with the instance id.ref HTMLDivElement | null – The wrapper element. Bindable with bind:ref.onActivate () => void – Called when the fade-in finishes.onDeactivate () => void – Called when the fade-out finishes....rest HTMLAttributes<HTMLDivElement> – class, style and any other attribute are forwarded to the wrapper.CSS variables
Variable Type Default Description
--beam-hue-base <angle> 0deg Rotates the whole palette.--beam-stroke-opacity <number> 1 Multiplier on the 1px beam stroke.--beam-inner-opacity <number> 1 Multiplier on the soft light inside the border.--beam-bloom-opacity <number> 1 Multiplier on the outer halo.--beam-spike-mul <number> 1 Line type only: how tall the travelling spikes rise.--pulse-glow-sx <number> 1 Pulse types: horizontal spread of the glow. pulse-outside sets it from the element size.--pulse-glow-sy <number> 1 Pulse types: vertical spread of the glow.--pulse-glow-boost <number> 1 Pulse types: scales the glow on both axes.Notes
pulse-outsidedraws its halo behind the element. Give the wrapped element an opaque background and its own 1px border, and leave unclipped space around it.- The beam is drawn on the wrapper, which is a block element. If the wrapped element is
narrower than its container, give the wrapper
style="width: fit-content"so the two stay the same size. - Beams pause while offscreen. The pulse types stop under
prefers-reduced-motion. - Works in Chrome 85, Safari 15.4 and Firefox 128 or newer. Without
@propertythe travelling beam steps instead of gliding.