Platform
VaultVault
  • Free15
  • Navigation19
  • Buttons9
  • Scroll55
  • Text27
  • Sliders & marquees19
  • Gallery & images67
  • Cursor24
  • Page transitions10
  • Loaders2
  • Backgrounds10
  • UI components33
ButtonsPart of ProButtons
IconsPart of ProIcons
  • Interface Essentials144
  • Social Icons69
  • Payment Badges41
SavedPart of ProSaved
Support
DocumentationDocumentation
MCP serverMCP server
SettingsSettings
VaultTextDraw-In Underline Link
Looping TypewriterBrowse all 182Variable Font Cursor
  • Free15
  • Navigation19
  • Buttons9
  • Scroll55
  • Text27
  • Sliders & marquees19
  • Gallery & images67
  • Cursor24
  • Page transitions10
  • Loaders2
  • Backgrounds10
  • UI components33
  • Interface Essentials144
  • Social Icons69
  • Payment Badges41
Sign inSign in

Start free. The code for 15 components, no card needed.

Get 15 free

Draw-In Underline Link

This one is locked. Become a member to open the code for it and the rest of the Vault.

See plansTry the 15 free ones

What you'll need.

Install

    Setup

    npm i gsap

    More like this

    • Link
    • Line drawing

    Features.

    • A 1px underline that draws in from the left on hover and slides off to the right on leave
    • Three starting states: hidden, half drawn from the left, or a short centred stub that grows out both ways
    • Keyboard focus draws the line too, with a 2px focus ring
    • The line uses the link's own colour, so it always matches the text
    • Speed and thickness are CSS variables: --unl-time and --unl-line
    • Pure CSS: no script, no dependencies
    • Respects prefers-reduced-motion: the line switches without animating

    How to get it right.

    Pick one start per context

    none is the quiet default for body links and lists. half hints that something is a link before you hover, which suits navigation. centre reads as a deliberate accent and works best on centred text.

    Keep links on one line

    The line spans the link's box. A link that wraps onto two lines gets one line under the whole box, not one per line of text. Keep links short, or use this for nav and lists rather than running text.

    Match the speed to the length

    The line takes the same --unl-time however long the link is. 0.6s suits a few words; drop it for single words, raise it for long headlines.

    Variations.

    • Hidden — the default: data-au-start="none", draws in from the left, leaves to the right
    • Half drawn — data-au-start="half": rests at half width and grows to full from the left
    • Centred — data-au-start="centre": a 25% stub in the middle that grows out both ways
    • Bold line — --unl-line: 2px for larger type
    • Your colour — set --unl-text; the line follows it

    Where it fits.

    • Navigation — header and footer links, often with half
    • Lists of articles or projects — one link per row
    • Contact details — email and phone links in a footer
    • Centred CTAs — a single "Read the story" under a headline, with centre

    Frequently asked.

    No. code.js is a comment only. Copy code.css and the markup.

    It works, but the link is inline-block and 1.125em, so it won't wrap and it's larger than body text. Set font-size: inherit on .unl_link for inline use and keep the link text short.

    On hover the line grows from the left; when you leave the origin flips to the right, so it slides off the far end instead of shrinking back. half and centre keep one origin both ways.

    Change the padding-bottom on .unl_link (0.22em). The line sits at the bottom of the padding.

    Related components.

    Pro

    Multi-Cursor Typing

    Load

    Pro

    Scroll-Lit Word List

    Scroll

    Pro

    Glitch Wipe Reveal

    Scroll