Border Beam
interlace-ui/border-beamFreeComponent
A single gradient square that travels around the inside edge of its parent, drawn with `offset-path` and a two-layer CSS mask so only the border ring shows. Drop it inside any `relative`, rounded container to give that container a moving outline.
Install it
npx shadcn@latest add https://ds.interlace.tools/r/border-beam.jsonSource
1"use client"23import { cn } from "@/lib/utils"4567// @interlace/border-beam v1.1.0 — Interlace design system.8// Docs, props and live preview: https://ds.interlace.tools/c/border-beam9// What changed since: https://ds.interlace.tools/c/border-beam#history10// Generated banner — keep it, the upgrade diff reads this version.1112/**13 * @interlace/ui — BorderBeam14 *15 * A single gradient square that travels around the inside edge of its parent,16 * drawn with `offset-path` and a two-layer CSS mask so only the border ring17 * shows. Drop it inside any `relative`, rounded container to give that18 * container a moving outline.19 *20 * It positions itself `absolute inset-0` and inherits the parent's radius, so21 * the only thing the parent has to supply is a stacking context.22 *23 * Our reimplementation of the Magic UI component of the same name, rebuilt on24 * CSS `offset-path` instead of Framer Motion — the whole effect is one25 * compositor-driven property and this file imports no animation library.26 *27 * ## Anatomy28 *29 * div (absolute inset-0, rounded-[inherit],30 * transparent border + mask-intersect —31 * this is what clips the beam to the ring)32 * └─ div.animate-border-beam (the beam: an aspect-square gradient33 * riding `offset-path: rect(… round Npx)`)34 *35 * ## Motion36 *37 * Pure CSS, and covered twice: `.animate-border-beam` is named in the38 * `prefers-reduced-motion: reduce` block in `styles/tokens.css`39 * (`animation: none !important`) and also caught by the `animation-duration`40 * wildcard in `styles/preflight.css`. There is no `useReducedMotion` call and41 * none is needed. Note what `reduce` leaves behind: with the animation off,42 * `offset-distance` sits at its initial `0%`, so the beam parks as a static43 * gradient square at the start of the path rather than disappearing.44 *45 * ## Colour, and why `--chart-2` is allowed here46 *47 * `colorFrom` / `colorTo` default to `var(--primary)` → `var(--chart-2)`, the48 * brand orange-to-green sweep. They were the raw literals `#ffaa40` / `#9c40ff`49 * (R19), which also meant the beam did not re-resolve per theme.50 *51 * `--chart-2` is a 3:1-class token, not a 4.5:1 one, and that is the right52 * choice HERE specifically: the beam is a decorative overlay inside a container53 * that draws its own `border`, so it is neither text (SC 1.4.3) nor the54// … truncated
More from interlace-ui
All 140 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| A11y Startera11y-starter | interlace-ui | Components | Free | no deps | |
| Accordionaccordion | interlace-ui | Components | Free | no deps | |
| Alertalert | interlace-ui | Components | Free | no deps | |
| Alert Dialogalert-dialog | interlace-ui | Components | Free | no deps | |
| Animated Gradient Textanimated-gradient-text | interlace-ui | Components | Free | no deps | |
| Animated Grid Patternanimated-grid-pattern | interlace-ui | Components | Free | no deps | |
| Animated Listanimated-list | interlace-ui | Components | Free | no deps | |
| Article Cardarticle-card | interlace-ui | Components | Free | no deps |
