Theme
Install with your agentnpx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-contents-nav.json --yes

Contents nav

Pro

A table of contents for a long reading page (an article, a guide, a help page), each link jumping to a section, for React and Tailwind CSS. Part of Goop Pro.

Scroll the guide and the nav marks the section being read; press a section (or Tab to it and press Enter) to jump there, the focus on its heading. Narrow the window: the nav becomes a bar that opens the whole list from the bottom edge, and the line under it says so. The guide is our own. The demo routes by the address’s #, so the nav is told not to write the section there (syncHash={false}); a jump leaves the address as it was.

When to use

  • A table of contents for a long reading page (an article, a guide, a help page), each link jumping to a section.

Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Contents nav on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

Terminal
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-contents-nav.json --yes
PROMPT
Add the Goop Contents nav to this project. The install steps are at https://goop.so/docs/install.md

Usage

TSX
import { ContentsNav, ContentsNavBar, ContentsNavList } from '@/components/ui/goop/contents-nav';

function StudyGuide() {
  return (
    <div className="flex flex-col gap-6 narrow:flex-row narrow:items-start">
      <ContentsNav
        sections={[
          { id: 'planning', title: 'Planning a study' },
          { id: 'consent', title: 'Consent', sections: [{ id: 'withdraw', title: 'When someone withdraws' }] },
          { id: 'sharing', title: 'Sharing findings' },
        ]}
        className="sticky top-0 bg-background narrow:w-pane-xs narrow:shrink-0"
      >
        <ContentsNavBar className="narrow:hidden" />
        <ContentsNavList className="max-narrow:hidden" />
      </ContentsNav>
      <article className="flex flex-col gap-6 min-w-0">
        <section id="planning" className="scroll-mt-16">
          <h2 className="text-xl font-semibold">Planning a study</h2>
          <p>Write down what you want to learn before you choose who to ask.</p>
        </section>
        <section id="consent" className="scroll-mt-16">
          <h2 className="text-xl font-semibold">Consent</h2>
          <h3 id="withdraw" className="scroll-mt-16 font-semibold">When someone withdraws</h3>
          <p>Delete the recording and its notes the same day.</p>
        </section>
        <section id="sharing" className="scroll-mt-16">
          <h2 className="text-xl font-semibold">Sharing findings</h2>
          <p>One page of what you heard, with the quotes that show it.</p>
        </section>
      </article>
    </div>
  );
}
  • Fits: record: aside (body: long).
  • Also known as: TableOfContents, Toc, OnThisPage, ScrollSpy, JumpLinks.
  • height, width, padding, gap, corner, background, text, motion: add no class for these.

API reference

Options
OptionTypeWhat it does
sectionsreadonly ContentsSection[]The page's sections, in the page's order: each `{ id, title, sections?
current?stringThe id of the section being read, when the caller tracks it; left out, the nav tracks it itself.
syncHash?boolean = trueWhether a jump puts #id in the address (replacing the entry, never adding one); true unless given.
Defaultsaria-label = 'Contents'
  • Types: ContentsSection = { id: string; title: string; sections?: readonly ContentsSection[] }
Parts
PartWhat it is
ContentsNavListThe list of the page's sections inside a ContentsNav, the one being read marked; a second level one step in
ContentsNavBarInside a ContentsNav on a phone; its props: contents-nav--bar.md
  • data-slot values (to select a part by): contents-nav, contents-nav-bar, contents-nav-bar-title, contents-nav-bar-value, contents-nav-item, contents-nav-label, contents-nav-link, contents-nav-list

ContentsNavBar

Inside a ContentsNav on a phone.

TSX
import { ContentsNavBar } from '@/components/ui/goop/contents-nav';

Options

  • countLabel?: (place: number, total: number) => string — The bar's place words, from the section's place and the count (3 of 7 unless given).
  • open?: boolean — Whether the sheet is open, when the caller holds it; left out, the bar holds it.
  • defaultOpen?: boolean = false — Whether the sheet is open at first, when the bar holds it; closed unless true.
  • onOpenChange?: (open: boolean) => void — Called with the sheet's next open state.
  • container?: HTMLElement | null — Where the sheet is portalled; the end of <body> when left out.
  • closeLabel?: string = 'Close contents' — The spoken name of the sheet's close button.
  • Also takes: onClick?: (event: MouseEvent) => void; disabled?: boolean

Keyboard

KeyWhat it does
TabMove to the next section's link
EnterJump to the section and move the focus to its heading

Accessibility

  • The native element answers the keyboard.
  • hover, active, focus-visible: the browser's own (:hover, :active, :focus-visible): write nothing

Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:

StateDrawn by
expandedthe attribute data-state=open
openthe attribute data-state=open
currentthe attribute aria-current=location

Motion

  • The part sets its own motion: add no transition or animation of your own.

Responsive behaviour

  • Use it on a page read at length whose sections each have a heading; an app's views go in the Sidebar, a page's tabs in Tabs. Give each section an id and a scroll-mt-* as tall as any sticky bar over it. Beside the text, the list, sticky (max-narrow:hidden); on a phone, the bar over the text instead (narrow:hidden). In an app routed by the hash, syncHash={false}, so a jump never replaces the route.

Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

goop.so/themes/meadow/components/contents-nav.md · the page as Markdown
Theme
Install with your agentnpx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-contents-nav.json --yes

Where would you like to start?

Free · now

The Goop plugin

A design system for your AI coding agent, so screen ten matches screen one.

/plugin marketplace add goop-so/skillsthen /plugin install goop@goopCodex, Cursor, ChatGPT, the Claude app and more: Connect Goop
FreePro

The components

Every part live, with its props, its keys and what an agent sees. Whole page and app templates, working with sample data.