Beta

Border Beam <mv-border-beam>

Animiertes Licht, das den Rand jeder beliebigen Box entlangläuft: ein Komet mit konstanter Geschwindigkeit, konische Lichtreflexe, ein wandernder Verlauf, gleitende Sterne oder ein elektrischer Rand.

KategorieEffekte
TypNur CSS (<mv-border-beam>)
StatusBeta
Keywordsborder, beam, shine, gradient-border, star-border, electric, conic, glow

When to use

  • A featured pricing plan, CTA card or new-feature box needs light traveling around its border
  • A primary button or card should get an animated gradient, star or electric outline
  • Several cards need offset beams to add a subtle sense of activity on a dark landing page

Avoid when

  • The element needs a soft halo behind it rather than an animated edge → use Glow instead
  • The border light should react to the cursor across a grid of cards → use Spotlight Card instead
  • Many boxes on the same screen would animate at once, diluting emphasis and adding motion noise

Installation

node scripts/add.mjs border-beam --out ./src/marvelous

KI-Agent mit dem MCP-Server von Marvelous UI: install_components({ slugs: ["border-beam"], target_dir: "<absolute path>/src/marvelous", framework: "react" }).

Kopierte Dateien (inklusive Abhängigkeiten): tokens/tokens.css, core/base.css, core/element.js, core/motion.js, core/observe.js, components/border-beam/border-beam.css, components/border-beam/border-beam.js.

Verwendung

Referenz-Markup zum Starten und Anpassen mit Attributen, data-* und CSS-Variablen:

<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,18rem),1fr));gap:1.25rem;width:100%;max-width:44rem;margin:auto">
  <article class="mv-card">
    <header class="mv-card-header">
      <h3 class="mv-card-title">Pro plan</h3>
      <p class="mv-card-description">beam: a comet travels the border</p>
    </header>
    <div class="mv-card-content">
      <div class="mv-card-stat">$29<span style="font-size:.9rem;font-weight:500;color:var(--mv-fg-muted)"> / month</span></div>
      <p style="margin:.5rem 0 0;color:var(--mv-fg-muted)">Unlimited projects, 10 seats, priority support.</p>
    </div>
    <footer class="mv-card-footer"><button class="mv-button" style="width:100%">Upgrade to Pro</button></footer>
    <span class="mv-border-beam" aria-hidden="true"></span>
  </article>

  <article class="mv-card">
    <header class="mv-card-header">
      <h3 class="mv-card-title">New: PDF exports</h3>
      <p class="mv-card-description">shine: rotating conic highlights</p>
    </header>
    <div class="mv-card-content">
      <p style="margin:0;color:var(--mv-fg-muted)">Generate signed reports in one click, straight from your dashboards.</p>
    </div>
    <span class="mv-border-beam" data-variant="shine" aria-hidden="true"></span>
  </article>

  <article class="mv-card">
    <header class="mv-card-header">
      <h3 class="mv-card-title">Writing assistant</h3>
      <p class="mv-card-description">gradient: a shifting gradient border</p>
    </header>
    <div class="mv-card-content">
      <p style="margin:0;color:var(--mv-fg-muted)">Rephrase, summarize and translate your content without leaving the editor.</p>
    </div>
    <span class="mv-border-beam" data-variant="gradient" aria-hidden="true"></span>
  </article>

  <article class="mv-card">
    <header class="mv-card-header">
      <h3 class="mv-card-title">Turbo mode</h3>
      <p class="mv-card-description">electric: a crackling border (JS)</p>
    </header>
    <div class="mv-card-content">
      <p style="margin:0;color:var(--mv-fg-muted)">4× faster builds on dedicated infrastructure.</p>
    </div>
    <mv-border-beam data-variant="electric" style="--mv-border-beam-color-from:oklch(0.78 0.15 220)"></mv-border-beam>
  </article>
</div>

<div style="display:flex;flex-wrap:wrap;gap:1rem;justify-content:center;align-items:center;margin-top:1.75rem">
  <button class="mv-button" data-variant="outline" data-shape="pill" data-size="lg">
    Book a demo
    <span class="mv-border-beam" data-variant="star" aria-hidden="true"></span>
  </button>
  <button class="mv-button" data-variant="secondary" data-size="lg" style="--mv-border-beam-size:3rem;--mv-border-beam-duration:4s">
    Join the beta
    <span class="mv-border-beam" aria-hidden="true"></span>
  </button>
  <button class="mv-button" data-variant="outline" data-size="lg" style="--mv-border-beam-size:3rem;--mv-border-beam-duration:4s">
    View the changelog
    <span class="mv-border-beam" data-reverse aria-hidden="true" style="--mv-border-beam-color-from:oklch(0.75 0.17 160);--mv-border-beam-color-to:oklch(0.85 0.12 200)"></span>
  </button>
</div>

API

Attributes

NameTypDefaultDescription
data-variantbeam | shine | gradient | star | electricbeambeam: a comet along the perimeter (offset-path, constant speed); shine: rotating conic highlights; gradient: a rotating gradient border, brighter on hover; star: two glows sliding along the top and bottom in opposite directions; electric: a crackling border (SVG filter, requires border-beam.js).
data-reversebooleanbeam variant: reverse direction.

Methods

NameDescription
ensureElectricFilter()JS export: injects the electric filter if you use the class on a <span> instead of the element.

Content structure

NameDescription
<mv-border-beam>Optional element form (border-beam.js): adds the class and aria-hidden; required for electric (injects the shared turbulence filter, paused off-screen and with reduced motion).

CSS classes

NameDescription
mv-border-beamDecorative layer to place as the last child of a positioned box (.mv-card, .mv-button…): <span class="mv-border-beam" aria-hidden="true">. Inherits the parent’s radius, masked into a ring.

CSS variables

NameDefaultDescription
--mv-border-beam-width1.5px (2px for gradient/star/electric)Ring thickness.
--mv-border-beam-size5remComet length / star glow size.
--mv-border-beam-duration6sDuration of one lap.
--mv-border-beam-delay0sStart delay.
--mv-border-beam-start0Start position (0 to 1) along the perimeter, to offset several beams.
--mv-border-beam-color-from / -via / -toaccent / pink / amberLight colors.
--mv-border-beam-offset18%Frozen comet position with reduced motion.
--mv-border-beam-radiusvar(--mv-radius-xl)Path radius when the browser can’t follow the box (offset-path: border-box).
--mv-border-beam-inset3pxelectric: stroke inset to leave room for the jitter.
--mv-border-beam-z3Layer z-index.

Accessibility

Purely decorative: aria-hidden, pointer-events: none. With reduced motion every variant freezes (the comet stays parked on the edge, the electric filter is paused).

Diese Seite wurde mit KI übersetzt. Übersetzungsfehler melden