Skip to content
WANCRAFT

C.131Typography & Text

Animated Link

Inline links with refined hover and focus underlines — slide, grow, double, highlight, arrow and wave — that follow line wraps.

NewReactCSSSVGTailwindbasic

Overview

Animated Link is a drop-in <a> with six considered underline animations: slide (draws in from the left and leaves to the right), grow from the centre, a double rule drawn from both ends, a highlighter sweep behind the text, an arrow that nudges forward, and an SVG wave that grows out of a flat line and flows while hovered. Every line is a background image on the inline element itself, so it follows wrapped lines — the draw runs across the first line and continues on the next. A faint resting underline keeps links recognisable without hover or colour, keyboard focus plays the same animation as hover alongside a visible focus ring, and external links get target and rel, an ↗ indicator and screen-reader text. With reduced motion the line simply appears.

01Installation

Method 01 · Registry

CLI verified

Uses the shadcn CLI in a project initialised with shadcn init. Installs the file to components/ui/animated-link.tsx and adds its dependencies.

npx shadcn@latest add https://wancraft.my/r/animated-link.json

Method 02 · Copy and paste

  1. 1. No extra dependencies — React and Tailwind CSS only.
  2. 2. Copy the source from the Code tab into components/ui/animated-link.tsx.
  3. 3. Import it and adjust props.
Dependencies
None
Peer
react ≥ 18, tailwindcss ≥ 4
Added
13 Oct 2026
Updated
—

02Usage

The default configuration. Change properties above to generate a tailored example in the Usage tab.

example.tsx
import { AnimatedLink } from "@/components/ui/animated-link";

export function AnimatedLinkExample() {
  return (
    <p className="text-lg">
      <AnimatedLink href="/notes">
        Read the field notes
      </AnimatedLink>
    </p>
  );
}

03Props

PropTypeDefaultDescription
variant"slide" | "grow" | "double" | "highlight" | "arrow" | "wave""slide"Underline animation.
colorstring"#FF7448"Colour of the animated line, highlight or wave (hex for the wave).
thicknessnumber2Animated line thickness in px.
offsetnumber2Space below the text for the line, in px (padding, so it never shifts layout).
durationnumber450Draw duration in ms.
restingLinebooleantrueFaint resting underline so the link is identifiable without hover or colour.
externalbooleanfalseAdds target="_blank", rel="noopener noreferrer", an ↗ glyph and screen-reader text.
externalLabelstring"(opens in new tab)"Screen-reader text for external links.
...propsAnchorHTMLAttributes—Forwarded to the <a> (href, target, rel, onClick…); the ref points to it.

04Features

  • 01Six underline animations, all painted as background images on the inline <a>
  • 02Works across line wraps: the line draws through the first line and continues on the next
  • 03Slide exits to the right instead of reversing
  • 04SVG wave grows out of a flat line and flows while engaged
  • 05External link indicator with target / rel handled
  • 06No layout shift: the line lives in bottom padding
motion · tweeninput · hoverinput · focus

05Accessibility

  • A real <a>; keyboard focus (focus-visible) plays the same animation as hover, plus a visible accent focus ring.
  • A faint resting underline keeps links distinguishable without relying on colour (on by default).
  • External links append visually hidden "(opens in new tab)" text; the ↗ and arrow glyphs are aria-hidden.
  • Touch taps do not leave a sticky hover state.
  • With prefers-reduced-motion the line appears without drawing, the arrow does not nudge and the wave does not flow.