Ir al contenido
Español
Borde con haz de luz viene con Pro. La vista previa aparece al desbloquearlo.

Cómo funciona

A track is laid over the container: its padding equals the border width and a mask removes the content box, leaving a faint ring. The beam is 12 dots, each moving at constant speed along offset-path: rect(), so length stays constant and the beam bends around corners. A second, blurred copy of the dots runs the same path in a layer masked to the outside of the border, so the head casts a halo on the surface around the container without ever covering its content. Browsers without rect() fall back to a rotating conic gradient.

Úsalo para

  • The input of an AI assistant or chat entry, to say “ready, start typing”.
  • The recommended plan on a pricing page.
  • The entry card of a new feature, to draw attention for a short time.

Busca otra opción cuando

  • Several beams on one screen: attention is split, so use at most one.
  • Form errors and warnings: the beam is decorative and cannot express severity; use colour and text.
  • Workspaces people stay on for long: constant motion tires the eye; start it only on focus or hover.

Uso

import { BorderBeam } from './BorderBeam.jsx'

export function PlanCard() {
  return (
    <BorderBeam radius={16} duration={6} colorFrom="#f97316" colorTo="#ec4899" style={{ padding: 20, background: '#fff' }}>
      <h3>Yearly plan</h3>
      <p>$198 / year · 4 free upgrades a month</p>
    </BorderBeam>
  )
}

Propiedades

PropiedadTipoPor defectoQué hace
durationnumber6Seconds per lap.
beamSizenumber90Beam length in px, measured along the border, whatever the container shape.
colorFromstring'#6366f1'Colour of the beam head.
colorTostring'#a855f7'Colour of the beam tail, which then fades to transparent.
borderWidthnumber1.5Border width in px. The container's inner padding must be larger.
radiusnumber16Corner radius in px, shared by the container and the beam track.
reversebooleanfalseCircles counter-clockwise.
delaynumber0Animation delay in seconds. With several beams on screen, use negative values to stagger the start.
glowbooleantrueAdds a soft halo outside the border that follows the beam head. It is masked to the outside of the container, so it never covers the content.
childrenReactNode—Container content. The container sets no background or shadow; use style or className.
...restHTMLAttributes<HTMLDivElement>—Other attributes go to the root <div>.

Accesibilidad

  • The track, beam and glow are aria-hidden decoration with pointer-events: none, so clicks and screen readers are unaffected.
  • With reduced motion the beam and glow stop and a static gradient outline is shown, which still marks the element as emphasised.
  • No information depends on the animation.

Movimiento

One lap takes 6s by default at constant speed (linear, as a loop must). There is no enter or exit animation.

Añádelo a tu proyecto

Los miembros Pro copian un prompt y su agente de programación instala el código, igual que con los gratuitos.

BorderBeam.jsxborder-beam.csstokens.cssREADME.md

Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.

Tarjetas
Tarjeta con borde animado viene con Pro. La vista previa aparece al desbloquearlo.
Tarjeta con hoja de datos viene con Pro. La vista previa aparece al desbloquearlo.
Sobre que se abre viene con Pro. La vista previa aparece al desbloquearlo.