Skip to content

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
import { AnimatedBorder } from "@/app/lib/components/animated-border";
example 1
<AnimatedBorder>
  <h2>Hello</h2>
  <p>Content inside the glowing border</p>
</AnimatedBorder>

API

Props

PropTypeDefault
children*ReactNode—
borderWidth

Border width in pixels. Default: 1.5

number1.5
borderRadius

Border radius in pixels. Default: 16

number16
className

Additional 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.