Skip to content

Block 22 of 297

Article with Contents

A long-form article in titled sections with a sticky table of contents on desktop and a collapsible one on phones.

Puck key
ArticleTocBlock
Export
articleTocBlock
React component
<ArticleToc />
Path
components/puck/article-toc-block.tsx
Dependencies
None
License
MIT

About this block

When to use it, how to write for it, and what to change in the code.

What it's for

A long article split into titled sections, with an "On this page" list of numbered anchor links. On desktop the list sticks in a side column as you scroll. On phones it becomes a collapsed panel above the text showing the section count. It works without JavaScript and fits guides, policies and explainers that people scan for one part.

  • A resident guide to a process like permits or tax appeals
  • Policy, eligibility or program rules pages
  • Annual report narratives or long explainers
Writing the content
  • Each section Heading also becomes its contents link, so write headings that make sense out of context.
  • The contents list appears only when two or more sections have headings.
  • In Body, blank lines start paragraphs, and a block where every line starts with "- " becomes a bulleted list.
  • Put author, date or reading time in Byline, and keep Lead paragraph to two or three sentences.
Accessibility
  • Section headings are one level below the title, and each contents list is a nav element named by the Contents label (WCAG 1.3.1).
  • The phone version uses native details and summary, so it opens with the keyboard and announces its state; links are at least 44px tall with a focus outline.
  • Headings use scroll-mt-24 so a jumped-to heading isn't hidden under a sticky site header, and the targeted heading's top rule turns indigo.
Customizing the code
  • Sticky offset is top-24 on the desktop nav and scroll-mt-24 on headings; match both to your header height.
  • Bullet markers and the active rule use indigo-600, set in the Prose helper and the target: class.

Editor fields

What content editors see in the P1 sidebar when they select this block.

  • Eyebrowtext
  • Titletextarea
  • Heading levelselect
  • Bylinetext
  • Lead paragraphtextarea
  • Contents labeltext
  • Sectionsarray