Cómo funciona
The border is the root's padding showing two background layers: a pointer light over a conic gradient that a registered angle turns, with no spinning oversized element. Most of the conic is the plain border colour and one long arc carries the palette, so at rest the card is calm and its edge only quietly alive. One window listener, throttled to animation frames, writes where on the edge the pointer is closest and how near it is (0 to 1); the border, a blurred glow underneath and a faint wash inside all brighten together as the pointer approaches.
Úsalo para
- The one recommended option among several, such as a plan or a template.
- A featured card that should invite the pointer without shouting.
Busca otra opción cuando
- Every card in a grid: the highlight loses its meaning.
- Error or warning states: use a plain coloured border.
Uso
import { AnimatedBorderCard } from './AnimatedBorderCard.jsx'
export function RecommendedPlan() {
return (
<AnimatedBorderCard as="article" palette="aurora" speed={8} proximity={160}>
<div style={{ padding: 24 }}>
<h3>Studio</h3>
<p>For small teams shipping every week.</p>
</div>
</AnimatedBorderCard>
)
}Propiedades
| Propiedad | Tipo | Por defecto | Qué hace |
|---|---|---|---|
children | ReactNode | — | Card content; give it its own padding. |
palette | 'aurora' | 'sunset' | 'mono' | 'aurora' | Colours of the travelling arc. |
speed | number | 8 | Seconds per full turn (minimum 1). |
borderWidth | number | 1.5 | Border thickness in px. |
proximity | number | 160 | Distance in px at which the pointer starts to light the border; 0 turns it off. |
glow | boolean | true | Soft coloured glow under the card. |
as | ElementType | 'div' | Root element. |
Accesibilidad
- Purely decorative: the border, glow and pointer light carry no information, and the card renders its children unchanged.
- The pointer effect listens passively and only on devices that hover; keyboard and touch users see the turning border alone.
- Forced-colors mode draws a solid border in the text colour.
- Reduced motion stops the turn and parks the arc on the top-right edge; the pointer light still responds, without movement.
Movimiento
The arc turns linearly once every 8s (adjustable), which reads as a slow drift. The glow under the card eases between strengths over 360ms; the pointer light follows every animation frame.
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.
AnimatedBorderCard.jsxanimated-border-card.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.







