WebberUI

Dot Leader Contents

A table of contents in book-index style — dot leaders extend dot by dot from left to right to meet the page number, and a preview card floats out from the end of the row on hover.

Loading preview…
npx shadcn@latest add https://webberui.com/r/dot-leader-contents.json

Playground

Tune the props live — the code snippet updates as you go, so you can dial in the look you want before copying it.

<DotLeaderContents />

Installation

npx shadcn@latest add https://webberui.com/r/dot-leader-contents.json

Installing also writes the --wb-duration-fast and --wb-ease-out CSS variables into your global stylesheet.

Usage

import { DotLeaderContents } from "@/components/ui/dot-leader-contents";

<DotLeaderContents
  items={[
    { id: "origin", title: "Chapter One: Origins", label: "01" },
    { id: "voyage", title: "Chapter Two: The Voyage", label: "02" },
  ]}
  onSelect={(id) => console.log(id)}
/>

Props

DotLeaderContents

PropTypeDefaultDescription
itemsDotLeaderItem[]The list of contents entries
onSelect(id: string) => voidFired when a row is clicked; when omitted, it falls back to scrolling to the page anchor matching id
classNamestringExtra classes for the outer <nav>

DotLeaderItem

FieldTypeDescription
idstringUnique identifier; passed to onSelect on click, or used as the page anchor id when no onSelect is provided
titlestringChapter title (left side of the row)
labelstringNumber or page-number string (right side of the row)
previewReactNodeOptional: preview content that floats out from the end of the row on hover (a thumbnail, a color swatch, and so on)

How it works

  • Reveal: whileInView plus stagger brings the rows in one by one; the dot leader extends from left to right via scaleX with origin-left, and the number fades in once the leader has connected
  • Dot leader: a repeating radial-gradient dot pattern inside an overflow-hidden container, colored with currentColor — no extra DOM nodes needed
  • Hover: the leader darkens, the title shifts 4px right, and the number scales up; rows with a preview float a preview card out from the end of the row (keyboard focus triggers it too)
  • When no onSelect is provided, clicking smooth-scrolls to the page anchor matching id
  • When the user has "reduce motion" enabled at the system level, the complete contents are shown directly, scrolling becomes an instant jump, and hover keeps only the color change

On this page