Underline Link
Text link with a line that draws in from the left and leaves to the right.
$npx shadcn@latest add https://framebrick.co/r/underline-link.jsonFrom the Nitip template, see it in context.
import { UnderlineLink } from "@/components/ui/underline-link";
export default function UnderlineLinkDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-10">
<UnderlineLink href="#">All projects</UnderlineLink>
<UnderlineLink href="#" arrow={false} thickness={2}>
Read the story
</UnderlineLink>
</div>
);
}Examples
Roll and two lines
The label rolls up, a faint line draws at once and the solid one follows half a second later.
import { UnderlineLink } from "@/components/ui/underline-link";
const links = ["Portfolio", "About", "Services", "Contact"];
/* Lookis' menu: the label rolls up, a faint line draws at once and the solid one follows half a second later. */
export default function UnderlineLinkRollDemo() {
return (
<nav aria-label="Example menu" className="grid w-fit grid-cols-2 gap-x-12 gap-y-4">
{links.map((link) => (
<UnderlineLink key={link} href="#" arrow={false} roll twoStep>
{link}
</UnderlineLink>
))}
</nav>
);
}<UnderlineLink href="/portfolio" arrow={false} roll twoStep>Portfolio</UnderlineLink>Two lines with an arrow
A faint line, the solid one half a second later, and the arrow turns with the second.
import { UnderlineLink } from "@/components/ui/underline-link";
/* Lookis' text link with an arrow: a faint line, the solid one half a second later, and the arrow turns with the second. */
export default function UnderlineLinkSecondaryDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-10">
<UnderlineLink href="#" twoStep>
See my portfolio
</UnderlineLink>
</div>
);
}<UnderlineLink href="/portfolio" twoStep>See my portfolio</UnderlineLink>Line that leaves at once
The line grows from the left and is gone the moment the pointer leaves.
import { UnderlineLink } from "@/components/ui/underline-link";
/* Marai Neesu's links: the line grows from the left and is gone at once when the pointer leaves. */
export default function UnderlineLinkInstantDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-10">
<UnderlineLink href="#" exit="instant">
More about me
</UnderlineLink>
<UnderlineLink href="#" arrow={false} exit="instant">
Free preview
</UnderlineLink>
</div>
);
}<UnderlineLink href="/about" exit="instant">More about me</UnderlineLink>Turning arrow
An arrow pointing up-right that turns 45° to point right while the line draws.
import { UnderlineLink } from "@/components/ui/underline-link";
/* An arrow pointing up-right that turns to point right while the line draws. */
export default function UnderlineLinkTurnDemo() {
return (
<div className="flex flex-col items-center gap-6">
<UnderlineLink href="#" arrow="turn">
Contact me
</UnderlineLink>
<UnderlineLink href="#" arrow="turn" exit="instant">
Start a project
</UnderlineLink>
</div>
);
}<UnderlineLink href="/contact" arrow="turn">Contact me</UnderlineLink>Sliding arrow
The line draws in and the arrow slides 4 px to the right; the line is gone at once when the pointer leaves.
import { UnderlineLink } from "@/components/ui/underline-link";
/* Compose Digi's text link: the line draws in from the left, the arrow slides 4px right, and the line is gone at once on leave. */
export default function UnderlineLinkNudgeDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-10">
<UnderlineLink href="#" arrow="nudge" exit="instant">
More details
</UnderlineLink>
<UnderlineLink href="#" arrow="nudge" exit="instant">
See more projects
</UnderlineLink>
</div>
);
}<UnderlineLink href="/services" arrow="nudge" exit="instant">More details</UnderlineLink>Installation
$ npx shadcn@latest add https://framebrick.co/r/underline-link.json1. Install the dependencies.
npm install motion clsx tailwind-merge2. Add
cn()tolib/utils.ts(skip if shadcn already created it).import { clsx, type ClassValue } from "clsx"; import { extendTailwindMerge } from "tailwind-merge"; /* tailwind-merge must know the site's type scale (globals.css) is a font size, not a text color — otherwise cn("text-h6 text-muted-foreground") drops text-h6. */ const twMerge = extendTailwindMerge({ extend: { classGroups: { "font-size": [{ text: ["display", "h1", "h2", "h3", "h4", "h5", "h6"] }] } }, }); export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); }3. Copy the component into
components/ui/underline-link.tsx."use client"; import * as React from "react"; import Link from "next/link"; import { motion, type HTMLMotionProps, type Variants } from "motion/react"; import { cn } from "@/lib/utils"; /* * Underline Link — a text link with a line that draws in on hover (from the Nitip "Secondary Button"). * The line grows from the left and leaves to the right; the optional arrow turns from ↘ to →. * External http(s) links open in a new tab. * `track` leaves a faint line under the label for the drawn one to pass over (Titen's text line links), and `current` * marks the page you are on: the line stays drawn and the link carries aria-current. * * Three options from the Lookis and Marai Neesu menus (2026-10-13): * - `roll`: the label rolls up as a copy of it comes from below, 28px on the bounce-0 spring, the roll of Flip Button. * - `exit="instant"`: the line is gone at once when the pointer leaves, instead of leaving to the right (Marai Neesu's). * - `twoStep`: Lookis' two-step line. A faint line (30%) draws as the hover starts, and the solid one draws over it half * a second into the hover, on a timer rather than a gesture: leaving earlier removes the faint line at once and the * solid one never starts. Leaving always removes both at once. The arrow's turn waits for the second step too. It * replaces `track`, and the lines run on the bounce-0 spring Lookis uses. * * `arrow="turn"` is the Brickfolio "Contact Me" (and Marai Neesu's Button/Secondary, the same Framer component): an arrow pointing up-right, * 5px after the label (the link's 4px gap and 1px), that turns 45° to point right while the line draws, on spring 500 / 60 / 1 in * Framer. Here it runs on the line's own spring (bounce 0.2, 0.4s): both are nearly without overshoot and the component has no * other, so the arrow and the line stay in step with `twoStep` and `exit`. It is Flip Button's `arrow="turn"`, the same glyph and * angle, so the two mean the same thing; `true` stays the arrow that turns from ↘ to →. Rotate is a transform, so MotionConfig stops it * for reduced motion. * * And one from the Compose Digi "Button/Secondary" (2026-10-20): `arrow="nudge"` draws a right arrow in a 20px box that slides * 4px to the right while the line draws (spring bounce 0.2, 0.4s), instead of turning. The line spans the whole link, label, * gap and arrow box — measured on the live site: 159.1px for a 134.1px label. With `exit="instant"` it is Compose Digi's link. */ const spring = { type: "spring", bounce: 0.2, duration: 0.4 } as const; const soft = { type: "spring", bounce: 0, duration: 0.4 } as const; /* The second line of `twoStep` starts this long into the hover (Lookis: 500ms). */ const STEP = 0.5; const MotionLink = motion.create(Link); export type UnderlineLinkProps = Omit<HTMLMotionProps<"a">, "href" | "children"> & { href: string; /** The arrow after the label: `true` turns it from ↘ to →; "nudge" draws a right arrow that slides 4px to the right instead; "turn" draws an up-right arrow that turns 45° to point right. */ arrow?: boolean | "nudge" | "turn"; /** Line thickness. */ thickness?: 1 | 2; /** A faint resting line under the label for the hover line to draw over (Titen's text line links). */ track?: boolean; /** Marks the link as the page you are on: aria-current, and the line stays drawn. */ current?: boolean; /** The label rolls up as a copy of it comes from below (Lookis' menu). */ roll?: boolean; /** How the line goes when the pointer leaves: to the right, or at once (Marai Neesu's menu). */ exit?: "right" | "instant"; /** A faint line first, the solid one 0.5s later over it; both go at once (Lookis' menu). Replaces `track`. */ twoStep?: boolean; children?: React.ReactNode; }; /* The line grows from the left when the hover starts, after `delay`; it leaves to the right or, `instant`, at once. */ const drawn = (transition: typeof spring | typeof soft, delay = 0, instant = false): Variants => ({ rest: instant ? { scaleX: 0, originX: 0, transition: { duration: 0 } } : { scaleX: 0, originX: 1, transition: { scaleX: transition, originX: { duration: 0 } } }, hover: { scaleX: 1, originX: 0, transition: { scaleX: { ...transition, delay }, originX: { duration: 0 } } }, }); export function UnderlineLink({ href, arrow = true, thickness = 1, track = false, current = false, roll = false, exit = "right", twoStep = false, className, children, ...props }: UnderlineLinkProps) { const external = /^https?:\/\//.test(href); const nudge = arrow === "nudge"; const turning = arrow === "turn"; const instant = exit === "instant" || twoStep; const lines = twoStep ? soft : spring; /* The current page shows its line at once: there is no hover to wait for. */ const secondDelay = twoStep && !current ? STEP : 0; const line = (variants: Variants, extra?: string) => ( <motion.span aria-hidden className={cn("absolute inset-x-0 bottom-0 bg-current", extra)} style={{ height: thickness }} variants={variants} /> ); return ( <MotionLink href={href} {...(external ? { target: "_blank", rel: "noopener noreferrer" } : {})} {...props} aria-current={current ? "page" : undefined} initial="rest" animate={current ? "hover" : "rest"} whileHover="hover" whileFocus="hover" className={cn( "relative inline-flex items-center gap-1 pb-0.5 text-sm font-medium whitespace-nowrap text-foreground outline-none", "rounded-xs focus-visible:ring-[3px] focus-visible:ring-ring/50", className, )} > {roll ? ( /* One line tall; the column holds both copies 8px apart, so one roll travels 28px (Flip Button's). The page you are on stays put. */ <span className="relative block h-5 overflow-hidden"> <motion.span className="flex flex-col gap-2" variants={{ rest: { y: 0 }, hover: { y: current ? 0 : -28 } }} transition={soft} > <span className="block leading-5">{children}</span> <span aria-hidden className="block leading-5"> {children} </span> </motion.span> </span> ) : ( children )} {nudge && ( /* A 20px box, 1px after the link's 4px gap: the arrow rests at its left and slides 4px right inside it. */ <span aria-hidden className="ml-px flex w-5 shrink-0"> <motion.svg viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round" className="size-4" variants={{ rest: { x: 0, transition: lines }, hover: { x: 4, transition: { ...lines, delay: secondDelay } }, }} > <path d="M3 8h10M9 4l4 4-4 4" /> </motion.svg> </span> )} {turning && ( <motion.svg aria-hidden viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round" className="ml-px size-4" variants={{ rest: { rotate: 0, transition: lines }, hover: { rotate: 45, transition: { ...lines, delay: secondDelay } }, }} > <path d="M4.5 11.5l7-7M5.5 4.5h6v6" /> </motion.svg> )} {arrow && !nudge && !turning && ( <motion.svg aria-hidden viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round" className="size-4" variants={{ rest: { rotate: 0, transition: lines }, hover: { rotate: -45, transition: { ...lines, delay: secondDelay } }, }} > <path d="M4.5 4.5l7 7M11.5 5.5v6h-6" /> </motion.svg> )} {/* The resting track sits under the drawn line, so the line appears to pass over it. */} {track && !twoStep && <span aria-hidden className="absolute inset-x-0 bottom-0 bg-current opacity-30" style={{ height: thickness }} />} {twoStep && !current && line(drawn(soft, 0, true), "opacity-30")} {line(drawn(lines, secondDelay, instant))} </MotionLink> ); }
Usage
import { UnderlineLink } from "@/components/ui/underline-link";
<UnderlineLink href="/projects">All projects</UnderlineLink>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| href | string | — | Link target. http(s) links open in a new tab. |
| arrow | boolean | "nudge" | "turn" | true | The arrow after the label: true turns it from ↘ to → on hover; "nudge" draws a right arrow that slides 4 px to the right instead (Compose Digi); "turn" draws an up-right arrow that turns 45° to point right (Brickfolio, Marai Neesu); false has none. |
| thickness | 1 | 2 | 1 | Line thickness in px. |
| track | boolean | false | A faint resting line under the label for the drawn one to pass over (Titen's text line links). |
| current | boolean | false | Marks the page you are on: the line stays drawn and the link carries aria-current. |
| roll | boolean | false | The label rolls up as a copy of it comes from below, 28 px on the bounce-0 spring — the roll of Flip Button (Lookis' menu). |
| exit | "right" | "instant" | "right" | How the line goes when the pointer leaves: out to the right, or at once (Marai Neesu's menu). |
| twoStep | boolean | false | A faint line (30%) draws as the hover starts and the solid one half a second later over it; both go at once. The arrow's turn waits for the second step too (Lookis' menu). Replaces track. |
| …props | anchor props | — | Passed to the link. |
- arrow="turn" is Brickfolio's "Contact Me" (and Marai Neesu's Button/Secondary, the same Framer component): an up-right arrow 5 px after the label that turns 45° to point right while the line draws. Framer runs both on spring 500 / 60 / 1; here the arrow rides the line's own spring (bounce 0.2, 0.4 s), nearly without overshoot like the original, so it stays in step with twoStep and exit. It is the glyph and angle of Flip Button's arrow="turn", so the two mean the same. true is still the arrow that turns from ↘ to →. Rotate is a transform, so MotionConfig stops it for reduced motion.
- The line also draws in on keyboard focus.
- twoStep runs on a timer, not a gesture: leaving before the half second removes the faint line at once and the solid one never starts. The current page shows its solid line straight away.
- roll copies the label, and the second copy is aria-hidden, so the link is named by the label once (a test that reads textContent sees it twice).
- arrow="nudge" is the Compose Digi "Button/Secondary": the arrow rests at the left of a 20 px box and slides 4 px right while the line draws, both on the bounce-0.2 spring. The line spans the whole link, arrow box included (measured on the live site: 159.1 px for a 134.1 px label). With exit="instant" it is Compose Digi's link exactly.
AI prompt
Paste into v0, Lovable, Bolt or Claude to rebuild this component in your own project.
Create a React + Tailwind CSS + Motion (motion/react) component called UnderlineLink using Next.js Link. - Inline-flex, text-sm font-medium text-foreground (shadcn defaults), 2px bottom padding. - An absolutely positioned line at the bottom (1px or 2px, bg-current). At rest scaleX 0; on hover scaleX 1. Grow from the left (transform-origin left) and shrink out to the right (transform-origin right) — switch the origin instantly. - Optional down-right arrow after the label that rotates -45° on hover so it points right. arrow="nudge" draws a right arrow (path "M3 8h10M9 4l4 4-4 4") in a 20px box, 1px after the gap, which slides x 0 → 4 on the same spring instead of turning. - Spring for both: bounce 0.2, duration 0.4s. The same animation runs on keyboard focus. - External http(s) links open in a new tab with rel noopener noreferrer. Colors from the theme (text-foreground). - Options. roll: the label sits in a one-line box (h-5, overflow-hidden) holding two copies 8px apart (the second aria-hidden), and the column moves -28px on hover, spring bounce 0, duration 0.4s. exit "instant": the line vanishes at once on leave (duration 0) instead of shrinking to the right. twoStep: a line at 30% opacity draws as the hover starts and the solid line draws over it with a 0.5s delay on its scaleX (and on the arrow's rotation), both vanishing instantly on leave, all on the bounce-0 spring; the current page draws only the solid line, with no delay.











