Playground

Border beam

A thin bordered box with a light that travels around its edge. CSS only.

  • Built on native elements
  • The beam is aria-hidden and decorative; the content keeps its normal reading order.
  • The beam is hidden under prefers-reduced-motion, leaving a plain thin border.
  • Styles in one file: border-beam.css

Import

import '@monoline/css';
import {BorderBeam} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add border-beam

Usage

import {BorderBeam} from '@monoline/react';

<BorderBeam style={{padding: 'var(--s6)', maxWidth: '24rem'}}>
  <p style={{margin: 0}}>A light travels the edge of this box.</p>
</BorderBeam>

Examples

Default

Slow

Props

BorderBeamProps

PropTypeDefaultDescription
durationnumber6Seconds for the light to travel once around. Default 6.

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

This component sets no state attributes.

CSS classes

ClassStylesheet
.border-beamborder-beam.css
.border-beam-lightborder-beam.css

Customization

Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.

app.css
.border-beam {
  border-color: var(--accent);
}

Accessibility

  • The beam is aria-hidden and decorative; the content keeps its normal reading order.
  • The beam is hidden under prefers-reduced-motion, leaving a plain thin border.