Moving Border

Moving Border provides an animated border effect built with Motion, SVG path measurement, and a moving gradient element. It exports both a ready-to-use Button component and a lower-level MovingBorder component.

Moving Border
LIVE · running in a sandboxed iframe
Installed with plain shadcn add · no workarounds · theme neutral (none shipped)
See how it was built

Installation

pnpm dlx shadcn@latest add @aceternity/moving-border

Requires @aceternity in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { Button } from "@/components/ui/moving-border";export function Example() {  return <Button onClick={() => console.log("clicked")}>Get started</Button>;}
  • Use for prominent calls to action that need a polished animated treatment.
  • Use for landing-page hero actions, signup buttons, and featured navigation links.
  • Use MovingBorder directly when applying the animated perimeter effect to a custom container.
  • Avoid using it for dense forms or interfaces where continuous motion may distract users.

Examples

Primary call to action

A prominent hero action using the exported Button component.

primary-call-to-action.tsx
import { Button } from "@/components/ui/moving-border";export function HeroAction() {  return <Button className="font-medium">Start building</Button>;}

Link-style action

Uses the polymorphic `as` prop to render an anchor.

link-style-action.tsx
import { Button } from "@/components/ui/moving-border";export function DocumentationLink() {  return (    <Button as="a" href="/docs" borderRadius="0.75rem">      Read the docs    </Button>  );}

Customized button colors

Adjusts the outer container, moving highlight, and inner content classes.

customized-button-colors.tsx
import { Button } from "@/components/ui/moving-border";export function CustomAction() {  return (    <Button      containerClassName="h-14 w-48"      borderClassName="bg-[radial-gradient(#a855f7_40%,transparent_60%)]"      className="border-purple-900 bg-purple-950/[0.8]"      duration={4500}    >      Explore plans    </Button>  );}

Direct MovingBorder usage

Applies the lower-level animated path effect to a custom panel.

direct-movingborder-usage.tsx
import { MovingBorder } from "@/components/ui/moving-border";export function AnimatedPanel() {  return (    <div className="relative h-32 overflow-hidden rounded-2xl bg-slate-950 p-[1px]">      <MovingBorder duration={4000} rx="12%" ry="12%">        <div className="h-16 w-16 bg-[radial-gradient(#22d3ee_40%,transparent_60%)] opacity-80" />      </MovingBorder>      <div className="relative flex h-full items-center justify-center rounded-2xl bg-slate-900 text-white">        Featured content      </div>    </div>  );}

API reference

PropTypeDefaultDescription
Button.borderRadiusstring"1.75rem"Controls the outer and inner border radius. The inner layers use `calc(borderRadius * 0.96)`.
Button.childrenReact.ReactNode—Content rendered inside the button's inner panel.
Button.asany"button"Element or component used as the outer wrapper. The source defaults to a native `button`.
Button.containerClassNamestring—Additional classes merged onto the outer wrapper, after the component's default classes.
Button.borderClassNamestring—Additional classes merged onto the moving gradient element.
Button.durationnumber—Animation duration passed to MovingBorder in milliseconds. MovingBorder itself defaults to 3000 milliseconds when this is undefined.
Button.classNamestring—Additional classes merged onto the inner content panel.
Button.[key: string]any—Any additional props are spread onto the outer `as` component, allowing attributes such as `onClick`, `href`, or `aria-label`.
MovingBorder.childrenReact.ReactNode—Element rendered at the animated position along the SVG rectangle path.
MovingBorder.durationnumber3000Time in milliseconds for the moving element to travel one complete path length.
MovingBorder.rxstring—SVG rectangle horizontal corner radius passed to the underlying `<rect>`.
MovingBorder.rystring—SVG rectangle vertical corner radius passed to the underlying `<rect>`.
MovingBorder.[key: string]any—Any additional props are spread onto the underlying `<svg>` element.

Accessibility

  • The Button component defaults to a native `<button>`, preserving native button semantics when the default `as` value is used.
  • When using `as="a"` or another custom element, provide the appropriate interaction semantics and keyboard behavior for that element.
  • The moving SVG and animated highlight are decorative and do not provide an accessible name or status; keep meaningful text in `children`.
  • Provide an `aria-label` when the visible children do not sufficiently describe the action; arbitrary props can be forwarded to the outer component.
  • The source does not implement reduced-motion handling, so consider adding an application-level motion preference strategy if continuous animation is inappropriate.

Docs written by openai:gpt-5.6-luna from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Moving Border" component (aceternity/moving-border) from its shadcn registry.1. Install it with: npx shadcn@latest add @aceternity/moving-border2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: Button.borderRadius, Button.children, Button.as, Button.containerClassName, Button.borderClassName, Button.duration, Button.className, Button.[key: string], MovingBorder.children, MovingBorder.duration, MovingBorder.rx, MovingBorder.ry, MovingBorder.[key: string].Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { Button } from "@/components/ui/moving-border";export function Example() {  return <Button onClick={() => console.log("clicked")}>Get started</Button>;}```

Files & dependencies

  • components/ui/moving-border.tsx→ components/ui/moving-border.tsx
dependenciesmotion

Looks similar, elsewhere