npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

svelte-border-beam

v0.1.0

Published

Animated border beam effect for Svelte 5 - a Svelte port of border-beam by Jakub Antalik. A lightweight component that adds a traveling or breathing glow animation around any element.

Readme

svelte-border-beam

Animated border beam effect for Svelte 5. A lightweight component that adds a traveling or breathing glow animation around any element - cards, buttons, inputs, or search bars.

This is a Svelte port of border-beam by Jakub Antalik. All of the visual design and the effect engine are his work - see the original repo and live demo. This package reimplements the React component wrapper with Svelte 5 runes and reuses his framework-agnostic CSS engine. Full attribution in CREDITS.md.

Install

npm install svelte-border-beam

Requires Svelte 5.

Quick start

<script>
  import { BorderBeam } from 'svelte-border-beam';
</script>

<BorderBeam>
  <div style="padding: 32px; border-radius: 16px; background: #1d1d1d;">
    Your content here
  </div>
</BorderBeam>

The component wraps your content and overlays the animated beam effect. It auto-detects the border-radius of the first child element. Anything you nest inside <BorderBeam> is passed as its children snippet.

Types

Built-in presets control the glow style and motion. They fall into two families.

Rotate (traveling beam)

<BorderBeam size="md"><Card /></BorderBeam>   <!-- Full border glow (default) -->
<BorderBeam size="sm"><IconButton /></BorderBeam>  <!-- Compact glow for small elements -->
<BorderBeam size="line"><SearchBar /></BorderBeam> <!-- Bottom-only traveling glow -->

Pulse (breathing glow, no rotation)

<BorderBeam size="pulse-inner"><Card /></BorderBeam>   <!-- Contained breathing border glow -->
<BorderBeam size="pulse-outside"><Card /></BorderBeam> <!-- Outward-blooming halo around the element -->

Both pulse types support all color variants, strength, theme, and the breathe speed via duration (defaults to 2.3).

pulse-outside requires an opaque wrapped child. The colorful core and halo render behind your content and bloom outward, so only the part that spills beyond the element shows. If your child is transparent, the inner glow will show through. The wrapper uses overflow: visible, so make sure the surrounding layout has room for the halo to spill.

pulse-outside relies on the wrapped element's own 1px border as the idle hairline. It does not paint its own hairline by default. If your child has no border, add a subtle 1px border (or box-shadow: inset 0 0 0 1px) so the edge stays defined while the beam is faded out.

Color variants

<BorderBeam colorVariant="colorful" /> <!-- Rainbow spectrum (default) -->
<BorderBeam colorVariant="mono" />     <!-- Grayscale -->
<BorderBeam colorVariant="ocean" />    <!-- Blue-purple tones -->
<BorderBeam colorVariant="sunset" />   <!-- Orange-yellow-red tones -->

All variants except mono animate through a hue-shift cycle.

Theme

Adapts beam colors for dark or light backgrounds:

<BorderBeam theme="dark" />  <!-- Dark background (default) -->
<BorderBeam theme="light" /> <!-- Light background -->
<BorderBeam theme="auto" />  <!-- Detects system preference -->

Strength

Control the overall intensity of the effect without affecting the wrapped content:

<BorderBeam strength={0.7}><Card /></BorderBeam> <!-- 70% intensity -->

strength accepts a value from 0 (invisible) to 1 (full intensity, default).

Play / pause

Toggle the animation on and off with smooth fade transitions:

<script>
  import { BorderBeam } from 'svelte-border-beam';
  let active = $state(true);
</script>

<button onclick={() => (active = !active)}>Toggle</button>

<BorderBeam {active} onDeactivate={() => console.log('faded out')}>
  <Card />
</BorderBeam>

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | children | Snippet | - | Content to wrap (nested content is used automatically) | | size | 'sm' \| 'md' \| 'line' \| 'pulse-outside' \| 'pulse-inner' | 'md' | Size/type preset | | colorVariant | 'colorful' \| 'mono' \| 'ocean' \| 'sunset' | 'colorful' | Color palette | | theme | 'dark' \| 'light' \| 'auto' | 'dark' | Background adaptation | | strength | number | 1 | Effect opacity (0-1), only affects the beam layers | | duration | number | 1.96 / 3.1 / 2.3 | Animation cycle duration in seconds (rotate / line / pulse) | | active | boolean | true | Whether the animation is playing | | borderRadius | number | auto-detected | Custom border radius in px | | brightness | number | per-type (1.3) | Glow brightness multiplier | | saturation | number | 1.2 | Glow saturation multiplier | | hueRange | number | 30 | Hue rotation range in degrees | | staticColors | boolean | false | Disable hue-shift animation | | class | string | - | Additional class on the wrapper | | style | string | - | Additional inline styles on the wrapper | | onActivate | () => void | - | Called when fade-in completes | | onDeactivate | () => void | - | Called when fade-out completes |

All standard HTMLDivElement attributes (id, role, aria-*, data-*, DOM event handlers, ...) are also forwarded to the wrapper.

How it works

BorderBeam renders a wrapper <div> with:

  • ::after - the beam stroke (rotate: conic gradient masked to the border; pulse: the colored perimeter ring / hairline)
  • ::before - inner glow layer (pulse-outside pushes this outward behind the content)
  • [data-beam-bloom] - outer bloom/glow child div

All effect layers are absolutely positioned and use pointer-events: none, so they never interfere with your content. The rotate and line types animate via CSS @property keyframes for smooth GPU-accelerated transitions. The pulse types drive their slow breathing from a single shared, frame-rate-capped (~30fps) requestAnimationFrame loop that writes plain CSS custom properties - so the breathing works even without @property support, repaints less often, and automatically pauses when the instance is inactive, offscreen, or the user prefers reduced motion.

Each instance injects a small, [data-beam="…"]-scoped <style> element containing its generated CSS, so multiple beams with different settings coexist without conflict.

Project structure

svelte-border-beam/
├── src/
│   ├── lib/
│   │   ├── index.ts          # Public exports
│   │   ├── BorderBeam.svelte  # Svelte 5 component (new)
│   │   ├── types.ts           # Type definitions (retyped for Svelte)
│   │   ├── styles.ts          # CSS generation engine (from original, logic unchanged)
│   │   └── pulseDriver.ts     # Shared rAF loop (from original, logic unchanged)
│   └── routes/                # SvelteKit demo site
├── LICENSE
├── CREDITS.md
└── README.md

Requirements

  • Svelte 5+
  • Modern browser with CSS @property support (Chrome 85+, Safari 15.4+, Firefox 128+)

Accessibility

The effect layers are purely decorative and use pointer-events: none. They do not affect keyboard navigation or screen readers. The pulse types ship a built-in prefers-reduced-motion: reduce block that disables their animations.

Development

npm install
npm run dev        # run the demo site
npm run build      # build the demo + package the library
npm run check      # type-check

Credits

Original border-beam React component, effect design, and all visual tuning by Jakub Antalik, github.com/Jakubantalik/border-beam. See CREDITS.md for details.

License

MIT - same as the original project.