Skip to content
MarkasUI
Type to search

    Guide

    MarkasUI

    Form

    Feedback

    Overlay

    Navigation

    Data

    Sections

    Animations

    Backgrounds

    Buttons

    Templates

    Pages

    Underline Link

    A link with an animated underline in five styles, including a hand drawn scribble. Shows on hover, on keyboard focus, and for the current page.

    <ul class="grid gap-3 text-base font-medium text-ink">
        <li><x-markas.underline-link href="#">Grow from the center</x-markas.underline-link></li>
        <li><x-markas.underline-link href="#" variant="slide">Slide in from the left</x-markas.underline-link></li>
        <li><x-markas.underline-link href="#" variant="comes-in-goes-out">Comes in, goes out</x-markas.underline-link></li>
        <li><x-markas.underline-link href="#" variant="goes-out-comes-in">Goes out, comes in</x-markas.underline-link></li>
        <li><x-markas.underline-link href="#" variant="scribble">Drawn by hand</x-markas.underline-link></li>
    </ul>
    import { UnderlineLink } from "@/components/markas/UnderlineLink";
    
    export default function UnderlineLinkExample() {
      return (
        <ul className="grid gap-3 text-base font-medium text-ink">
          <li>
            <UnderlineLink href="#">Grow from the center</UnderlineLink>
          </li>
          <li>
            <UnderlineLink href="#" variant="slide">
              Slide in from the left
            </UnderlineLink>
          </li>
          <li>
            <UnderlineLink href="#" variant="comes-in-goes-out">
              Comes in, goes out
            </UnderlineLink>
          </li>
          <li>
            <UnderlineLink href="#" variant="goes-out-comes-in">
              Goes out, comes in
            </UnderlineLink>
          </li>
          <li>
            <UnderlineLink href="#" variant="scribble">
              Drawn by hand
            </UnderlineLink>
          </li>
        </ul>
      );
    }
    <script setup lang="ts">
    import UnderlineLink from "@/components/markas/UnderlineLink.vue";
    </script>
    
    <template>
      <ul class="grid gap-3 text-base font-medium text-ink">
        <li><UnderlineLink href="#">Grow from the center</UnderlineLink></li>
        <li>
          <UnderlineLink href="#" variant="slide"
            >Slide in from the left</UnderlineLink
          >
        </li>
        <li>
          <UnderlineLink href="#" variant="comes-in-goes-out"
            >Comes in, goes out</UnderlineLink
          >
        </li>
        <li>
          <UnderlineLink href="#" variant="goes-out-comes-in"
            >Goes out, comes in</UnderlineLink
          >
        </li>
        <li>
          <UnderlineLink href="#" variant="scribble">Drawn by hand</UnderlineLink>
        </li>
      </ul>
    </template>
    <script lang="ts">
      import UnderlineLink from "$lib/components/markas/UnderlineLink.svelte";
    </script>
    
    <ul class="grid gap-3 text-base font-medium text-ink">
      <li>
        <UnderlineLink href="#">Grow from the center</UnderlineLink>
      </li>
      <li>
        <UnderlineLink href="#" variant="slide"
          >Slide in from the left</UnderlineLink
        >
      </li>
      <li>
        <UnderlineLink href="#" variant="comes-in-goes-out"
          >Comes in, goes out</UnderlineLink
        >
      </li>
      <li>
        <UnderlineLink href="#" variant="goes-out-comes-in"
          >Goes out, comes in</UnderlineLink
        >
      </li>
      <li>
        <UnderlineLink href="#" variant="scribble">Drawn by hand</UnderlineLink>
      </li>
    </ul>
    ---
    import UnderlineLink from "@/components/markas/UnderlineLink.astro";
    ---
    
    <ul class="grid gap-3 text-base font-medium text-ink">
      <li>
        <UnderlineLink href="#">Grow from the center</UnderlineLink>
      </li>
      <li>
        <UnderlineLink href="#" variant="slide">Slide in from the left</UnderlineLink>
      </li>
      <li>
        <UnderlineLink href="#" variant="comes-in-goes-out">Comes in, goes out</UnderlineLink>
      </li>
      <li>
        <UnderlineLink href="#" variant="goes-out-comes-in">Goes out, comes in</UnderlineLink>
      </li>
      <li>
        <UnderlineLink href="#" variant="scribble">Drawn by hand</UnderlineLink>
      </li>
    </ul>
    import { Component } from "@angular/core";
    import { UnderlineLink } from "./markas/underline-link.component";
    
    @Component({
      selector: "markas-example",
      imports: [UnderlineLink],
      template: `
        <ul class="grid gap-3 text-base font-medium text-ink">
          <li><a markas-underline-link href="#">Grow from the center</a></li>
          <li>
            <a markas-underline-link href="#" variant="slide">
              Slide in from the left
            </a>
          </li>
          <li>
            <a markas-underline-link href="#" variant="comes-in-goes-out">
              Comes in, goes out
            </a>
          </li>
          <li>
            <a markas-underline-link href="#" variant="goes-out-comes-in">
              Goes out, comes in
            </a>
          </li>
          <li>
            <a markas-underline-link href="#" variant="scribble">Drawn by hand</a>
          </li>
        </ul>
      `,
    })
    export default class UnderlineLinkExample {}

    Examples

    Navbar with current page

    Footer links

    Links in an article

    Installation

    npx markasui@latest add underline-link

    Usage

    <nav class="flex gap-5 text-sm font-medium">
        <x-markas.underline-link href="/" active>Home</x-markas.underline-link>
        <x-markas.underline-link href="/docs" variant="comes-in-goes-out">Docs</x-markas.underline-link>
    </nav>
    <x-markas.underline-link href="/guide" variant="scribble">Migration guide</x-markas.underline-link>
    import { UnderlineLink } from "@/components/markas/UnderlineLink";
    
    <nav className="flex gap-5 text-sm font-medium">
      <UnderlineLink href="/" active>Home</UnderlineLink>
      <UnderlineLink href="/docs" variant="comes-in-goes-out">Docs</UnderlineLink>
    </nav>
    <UnderlineLink href="/guide" variant="scribble">Migration guide</UnderlineLink>
    <template>
      <nav class="flex gap-5 text-sm font-medium">
        <UnderlineLink href="/" active>Home</UnderlineLink>
        <UnderlineLink href="/docs" variant="comes-in-goes-out">Docs</UnderlineLink>
      </nav>
      <UnderlineLink href="/guide" variant="scribble"
        >Migration guide</UnderlineLink
      >
    </template>
    <script lang="ts">
      import UnderlineLink from "$lib/components/markas/UnderlineLink.svelte";
    </script>
    
    <nav class="flex gap-5 text-sm font-medium">
      <UnderlineLink href="/" active>Home</UnderlineLink>
      <UnderlineLink href="/docs" variant="comes-in-goes-out">Docs</UnderlineLink>
    </nav>
    <UnderlineLink href="/guide" variant="scribble">Migration guide</UnderlineLink>
    ---
    import UnderlineLink from "@/components/markas/UnderlineLink.astro";
    ---
    
    <nav class="flex gap-5 text-sm font-medium">
      <UnderlineLink href="/" active>Home</UnderlineLink>
      <UnderlineLink href="/docs" variant="comes-in-goes-out">Docs</UnderlineLink>
    </nav>
    <UnderlineLink href="/guide" variant="scribble">Migration guide</UnderlineLink>
    import { Component } from "@angular/core";
    import { UnderlineLink } from "./markas/underline-link.component";
    
    @Component({
      selector: "app-site-nav",
      imports: [UnderlineLink],
      template: `
        <nav class="flex gap-5 text-sm font-medium">
          <a markas-underline-link href="/" active>Home</a>
          <a markas-underline-link href="/docs" variant="comes-in-goes-out">Docs</a>
        </nav>
        <a markas-underline-link href="/guide" variant="scribble"
          >Migration guide</a
        >
      `,
    })
    export class SiteNav {}

    Angular uses an attribute selector on the native link, so target, rel, aria-*, and class stay on it. No script in Astro: the line is pure CSS.

    • Pure CSS, no JavaScript. The line appears on hover, on keyboard focus, and stays visible with active, which also sets aria-current="page".
    • The line and the scribble use currentColor, so they follow the text color of the link.
    • The link is inline-block so the line sits under the whole label; keep labels on one line.
    • With reduced motion, the line appears without a transition.

    Props

    NameTypeDefaultDescription
    hrefstring-Link target. Schemes other than http, https, mailto, and tel are replaced with #.
    variant"grow-center" | "slide" | "comes-in-goes-out" | "goes-out-comes-in" | "scribble""grow-center"grow-center grows from the middle, slide grows from and returns to the left, comes-in-goes-out enters from the left and leaves to the right, goes-out-comes-in is visible at rest and redraws itself, scribble draws a hand drawn stroke.
    activebooleanfalseMark the link as the current page with aria-current="page" and keep the line visible.

    Accessibility

    • A native a element; the line and scribble are decorative and aria-hidden.
    • The line also appears on keyboard focus, next to a visible focus outline.
    • active sets aria-current="page", so the current page is announced, not only drawn.
    • With reduced motion, the line appears without a transition.

    Related components

    More animations components with the same classes in every framework.