Animated border
Card with a rotating conic gradient border. Colours shift based on cursor position via pastelColour — every spot on screen produces a unique palette.
- Spring Physics
- Conic Gradient
- requestAnimationFrame
Animated border
A rotating conic gradient border whose colours shift with your cursor position. Every spot on screen produces a unique palette.
Usage
Drop it in
import { AnimatedBorder } from "@/app/lib/components/animated-border";<AnimatedBorder>
<h2>Hello</h2>
<p>Content inside the glowing border</p>
</AnimatedBorder>API
Props
| Prop | Type | Default |
|---|---|---|
children* | ReactNode | — |
borderWidthBorder width in pixels. Default: 1.5 | number | 1.5 |
borderRadiusBorder radius in pixels. Default: 16 | number | 16 |
classNameAdditional class names for the outer wrapper | string | "" |
Read from the component's source at build time. * required.
Accessibility
Works with
- Cursor
- Reacts to where the pointer is, not just whether it's over the element.
- Touch
- Follows your finger while it's down, then settles a moment after you lift.
- Keyboard
- Focus lights it up the way the cursor does. Every action has a key.
- Reduced motion
- Nothing moves or springs. Colour still answers, without drifting.