Components

Underline

A pen line under real words: single, double, wavy or scribbled, in felt, pencil or marker. It follows the phrase line by line when it wraps, and can draw itself on as it scrolls into view.

Install

terminal
npx shadcn@latest add @wobko/underline

First time here? Add the registry to components.json first. How to install

Examples

Default

A felt-tip line under a phrase. It rises a little to the right, starts a hair early and runs past the last letter.

Kinds and pens

Single, double, wavy and scribbled lines; felt, blue felt, red felt, pencil and marker; fine, regular and brush.

Wraps, and draws on

An underline that wraps onto several lines is one pull per line. Press replay to watch it being drawn.

Under a headline

A double brush line under a title, a wavy pencil line under a caption: the pen grows with the type.

API reference

Underline

A <span> (or your own element with asChild) that hosts the drawing. One aria-hidden line per line of the phrase, measured from the browser's own line boxes.

PropTypeDefaultDescription
kind"single" | "double" | "wavy" | "scribble""single"The line. Single rises to the right like a real one; double is two pulls; wavy is a squiggle; scribble is a fast zig-zag.
tone"ink" | "blue" | "red" | "green" | "pencil" | "marker" | "orange""ink"The pen. Blue is the reserved "you" felt; red is for corrections.
weight"fine" | "regular" | "brush""regular"Fine-liner, felt tip or brush pen. Text under 15 px takes the fine-liner by itself, and the pen grows with larger type.
animatebooleanfalseDraw the line on, left to right, the first time the phrase scrolls into view. Reduced motion just shows it.
showbooleantrueShow or hide the line. With animate, turning it on plays the draw-on.
delaynumber-Milliseconds to wait before the first line draws on; each further line follows a beat later.
seedstring | number-Pins the hand. Default: derived from useId(), so server and client draw the same line.
asChildbooleanfalseRender the line on your own child element (a link, a strong).

Accessibility

  • The words are ordinary text: selectable, copyable, found by search. The line is aria-hidden and pointer-events-none.
  • Until the drawing exists (no JavaScript, first paint) and in Windows high contrast, the browser's own text-decoration underline is shown in the pen's color.
  • Do not use it as the only sign of a link: put it on a real <a> with asChild (links keep their native focus ring) or keep the link's own underline.
  • Reduced motion (or data-motion="reduced") zeroes the draw-on.

Source

The files the CLI copies into your project.

Loading the source