Border Beam for React
Border beam is an animated gradient border for React: a comet of light that runs around a rounded edge at one steady speed. Use it as a glowing border animation to mark the recommended plan in a pricing table, so one GlassCard carries a comet of light around its edge while the other tiers stay calm.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/border-beam.jsonDeploying to production
Build 2f9c1a, 14 of 18 steps
On a glass card
Drop it inside any positioned, rounded element: it takes the parent's radius and sits on its border. paused holds the beam exactly where it is.
Deploying to production
Build 2f9c1a · 14 of 18 steps
import { useState } from "react";
import { BorderBeam } from "@/components/sheenui/border-beam/border-beam";
import { GlassCard } from "@/components/sheenui/glass-card/glass-card";
import { Switch } from "@/components/sheenui/switch/switch";
// Package build (after the first npm release, or a packed tarball): import { BorderBeam, GlassCard, Switch } from "@sheenui/theme";
// This example also uses glass-card, switch: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/glass-card.json https://lokendra-builds.github.io/sheenui/r/switch.json
export function Example() {
const [paused, setPaused] = useState(false);
return (
<>
<Switch label="Pause the beam" checked={paused} onCheckedChange={setPaused} />
<GlassCard className="relative w-full max-w-sm p-6">
<h3 id="deploying-to-production" className="font-semibold">Deploying to production</h3>
<p className="text-sm text-sheen-fg-muted">Build 2f9c1a · 14 of 18 steps</p>
<BorderBeam paused={paused} />
</GlassCard>
</>
);
}Files to copy
4 folders · 4 files · 4 packages
- From
theme/src/ components/border-beam/hooks/{use-intersection.ts, use-media-query.ts, use-preferences.ts}lib/cn.tsstyles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/border-beam.jsonRegistry item: border-beam. The styles need the Tailwind v4 glass UI setup.- The examples also use
components/button/components/glass-card/components/input/components/spinner/components/switch/hooks/{use-direction.ts, use-latest.ts, use-magnetic.ts}motion/{gate.ts, light-follower.ts, tokens.ts}lib/{field-control-shell.tsx, field-size.ts, form.ts, heading.ts, motion-props.ts, state-light.tsx}
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/glass-card.json https://lokendra-builds.github.io/sheenui/r/input.json https://lokendra-builds.github.io/sheenui/r/switch.json- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
Wide bars, two beams, any color
On a wide search bar the beam keeps its pace along the long sides. double runs two beams on opposite sides; colors take any CSS color (here the warning and danger tokens).
import { BorderBeam } from "@/components/sheenui/border-beam/border-beam";
import { Button } from "@/components/sheenui/button/button";
import { GlassCard } from "@/components/sheenui/glass-card/glass-card";
import { Input } from "@/components/sheenui/input/input";
// Package build (after the first npm release, or a packed tarball): import { BorderBeam, Button, GlassCard, Input } from "@sheenui/theme";
import { Search as SearchIcon } from "lucide-react";
// This example also uses button, glass-card, input: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/glass-card.json https://lokendra-builds.github.io/sheenui/r/input.json
export function Example() {
return (
<>
<div className="relative w-full max-w-xl rounded-sheen-md">
<Input aria-label="Ask anything" placeholder="Ask anything…" leading={<SearchIcon />} />
<BorderBeam length={160} duration={6} />
</div>
<Button variant="glass" size="lg" className="rounded-sheen-full">
Upgrade
<BorderBeam double duration={5} />
</Button>
<GlassCard className="relative p-5">
2 alerts need attention
<BorderBeam reverse duration={7} colorFrom="var(--sheen-warning)" colorTo="var(--sheen-danger)" />
</GlassCard>
</>
);
}Props
Keyboard
Accessibility
- Purely decorative: aria-hidden, no focus, no pointer events, and hidden in forced colors.
- It sits on a card you provide, so contrast is that of the card. Under reduced motion it is a still beam lit on the top-left corner.
When to use the border beam effect
- Use it on the recommended plan of a pricing table or one featured card in a grid, so a single comet of light circles that edge while its neighbours stay still.
- Use it on a focused input wrapper or a primary call-to-action button to show an AI prompt box is live or that a card is selected, without adding a heavy glow.
- Use double and reverse to make a featured tile look different from its neighbors, and delay to stagger several beams so they never run in lockstep.
- Skip it when the surface is not a rounded element you control or you need a static highlight; a plain border, or SpotlightCard for a hover-driven glow, fits better than a looping animation.
- Pair it with GlassCard as the parent, Badge for a Recommended label, and Button inside the card so the beam draws attention to the action rather than competing with it.
Frequently asked questions
Related pages
19 effects pages in all: browse them on All effects.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .