Border Beam
A fine trace of light that travels around a surface and brings its edges to life.
GOOD IDEAS DESERVE THE SPOTLIGHT
Made to
stand out.
Follow the finer details.
Live component. Go ahead, interact.
Accent
REACT / TYPESCRIPT
import type { CSSProperties, HTMLAttributes } from 'react'
import './border-beam.css'
export interface BorderBeamProps extends HTMLAttributes<HTMLDivElement> {
/** Seconds for the light to travel once around the edge. */
duration?: number
color?: string
paused?: boolean
}
/** A luminous edge that leaves child content and focus outlines unobstructed. */
export function BorderBeam({
children,
className = '',
duration = 8,
color = '#f19451',
paused = false,
style,
...props
}: BorderBeamProps) {
const seconds = Number.isFinite(duration) ? Math.min(180, Math.max(1, duration)) : 8
const beamColor = color.trim()
const safeColor = beamColor && beamColor.length <= 200 && !/[;{}<>]/.test(beamColor)
? beamColor
: '#f19451'
return (
<div
{...props}
className={`ac-border-beam ${className}`.trim()}
data-paused={paused || undefined}
style={{
'--ac-border-beam-duration': `${seconds}s`,
'--ac-border-beam-color': safeColor,
...style,
} as CSSProperties}
>
{children}
</div>
)
}
01
Installation
Run this in your shadcn-configured React project. The component and stylesheet are added together.
TERMINAL
npx shadcn@latest add http://localhost:5173/r/border-beam.jsonThis command uses the current site address. For localhost, keep this preview running on the same computer. Files follow your configured components alias.
02
Usage
Import the component and make the details your own.
TypeScript
import { BorderBeam } from '@/components/anticraft/BorderBeam';
export function Example() {
return (
<BorderBeam style={{ padding: '2rem' }}>
<h3>Worth a closer look.</h3>
<p>Let the details do the talking.</p>
</BorderBeam>
);
}03
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Content inside the bordered surface. |
duration | number | 8 | The duration of a complete border loop in seconds, clamped between 1 and 180. |
color | string | '#f19451' | The CSS accent color of the moving beam. |
paused | boolean | false | Pauses the border animation. |
className | string | '' | Additional classes. Native div attributes and inline styles are supported. |
04
Motion & accessibility
Considered by default.
The moving border becomes a static accent when reduced motion is preferred.
Use semantic content and meaningful labels in your composition. Check contrast and keyboard behavior with your own styles and content.