zanwei

Table of Content

Navigation 47

About

A dependency-free vertical table of content with pointer scrubbing, keyboard navigation, spring-driven tick magnification, and floating section previews.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Table of Content to your project and fits it to your theme.

Code

How Table of Content is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import TableOfContent from "@/components/ui/table-of-content";

const items = [
  {
    id: "interaction-geometry",
    title: "Define the interaction geometry · 01",
    description:
      "Map the rail, tick spacing, preview anchor, and safe component bounds.",
  },
  {
    id: "pointer-selection",
    title: "Connect pointer position to selection · 02",
    description:
      "Choose the nearest record while preserving a continuous visual center.",
  },
  {
    id: "tick-spring",
    title: "Tune the tick spring · 03",
    description:
      "Keep magnification interruptible, quick, and close to critical damping.",
  },
  {
    id: "content-transitions",
    title: "Keep content transitions crisp · 04",
    description:
      "Replace title and description immediately without blur or decorative effects.",
  },
  {
    id: "measure-card",
    title: "Measure the card from typography · 05",
    description:
      "Let font metrics, wrapping, spacing, and padding determine card height.",
  },
  {
    id: "clamp-preview",
    title: "Clamp the preview at both edges · 06",
    description:
      "Keep every card inside the component while maintaining its visual anchor.",
  },
  {
    id: "touch-input",
    title: "Support direct touch input · 07",
    description:
      "Use Pointer Capture so scrubbing continues reliably through the gesture.",
  },
  {
    id: "keyboard-navigation",
    title: "Complete keyboard navigation · 08",
    description:
      "Arrow keys move by item, Home and End jump, and Escape closes the preview.",
  },
  {
    id: "reduced-motion",
    title: "Respect reduced motion · 09",
    description:
      "Preserve immediate selection while removing spatial interpolation.",
  },
  {
    id: "lifecycle-cleanup",
    title: "Verify lifecycle cleanup · 10",
    description:
      "Release observers, timers, listeners, and animation frames on disconnect.",
  },
];

export default function TableOfContentDemo() {
  return (
    <TableOfContent
      items={items}
      label="Document contents"
      value={4}
      open
    />
  );
}

More by zanwei

View all
  • Claude Model Selector

    Claude Model Selector

    109
  • ChatGPT Model Selector

    ChatGPT Model Selector

    70
  • Ball Model Picker

    Ball Model Picker

    58
  • Status Indicator

    Status Indicator

    40
  • Liquid Connector

    Liquid Connector

    30
  • Model Picker

    Model Picker

    27
  • Gradient Shimmer Text

    Gradient Shimmer Text

    23
  • Shared Element Transition Dialog

    Shared Element Transition Dialog

    11

More in Navigation

View all
  • Sidebar

    Sidebar

    234
  • Navbar with Theme Toggle

    Navbar with Theme Toggle

    43
  • Sidebar

    Sidebar

    339
  • Tabs

    Tabs

    60
  • Numberless Pagination with Text

    Numberless Pagination with Text

    11
  • Oversized 404 Numeral

    Oversized 404 Numeral

    50
  • Footer

    Footer

    446
  • Pagination

    Pagination

    43