Skip to documentation content

Pulsing Border

Wrap an element in an animated glow ring that signals activity, such as an AI model generating a reply.

pulsing-border-demo

Overview

Pulsing Border draws a soft ring of light around any rounded element. Colored spots drift around the outline at their own pace, the glow breathes, and optional smoke breaks the bloom into wisps. Use it to show that something is working on the user's behalf: a prompt field while a model generates a reply, a card while an agent runs, or a call to action that needs attention.

The ring is drawn on a canvas that sits over the element and extends past its edges by the bloom distance. That canvas ignores pointer events and is positioned absolutely, so the wrapped element keeps its own layout, focus ring, and click targets. Toggle active to fade the glow in and out; the render loop stops while the glow is hidden.

Installation

npm install honestui

Usage

import { PulsingBorder } from "honestui/shaders"

<PulsingBorder active={isGenerating} radius={14}>
  <form className="rounded-[14px] border bg-background p-2">
    <textarea aria-label="Prompt" />
  </form>
</PulsingBorder>

Set radius to the wrapped element's border radius so the ring hugs its corners. Ancestors with overflow: hidden clip the bloom, so leave room around the element or reduce bloom.

Examples

AI prompt field

The glow stays off while the field waits for input and fades in only while a reply is being generated, so it carries state. The status text below the field announces the same state to screen readers.

pulsing-border-ai-input

Accessibility

The glow is decorative and hidden from assistive technology. When it signals a state such as "generating", announce that state in text as well, for example with a live region or the button's accessible name, and never rely on the glow alone.

When the user prefers reduced motion, the ring renders one still frame and fades instead of animating. Browsers without WebGL2 get a still CSS ring in the same colors. Keep intensity moderate so the ring never reduces the contrast of the element's own border or focus indicator.

API Reference

PropTypeDefaultDescription
activebooleantrueShows the glow. Changing it fades the ring in or out.
colorsstring[]["#4f8bff", "#a35bff", "#ff5fb4", "#ffa53d"]Hex colors carried around the ring, up to 8.
radiusnumber16Corner radius in pixels. Match the wrapped element.
thicknessnumber1.5Width of the bright core line in pixels.
softnessnumber0.35Blur of the core line, from 0 to 1.
intensitynumber1Overall brightness, from 0 to 2.
bloomnumber22Reach of the outer glow in pixels.
innerGlownumber8Reach of the glow into the element in pixels.
spotsnumber4Number of light spots travelling around the ring, from 1 to 8.
spotSizenumber0.7Length of each spot relative to the space between spots.
pulsenumber0.35Breathing strength, from 0 to 1.
speednumber1Animation speed multiplier.
smokenumber0.25Wispy noise in the glow, from 0 to 1.
smokeScalenumber1Size of the smoke wisps.
pausedbooleanfalseFreezes the animation on its current frame.
glowClassNamestring–Classes for the glow layer, for example to change its stacking order.
classNamestring–Classes for the wrapper. Other div props and a ref are passed through.