Table of contents

A table of contents built from the page's headings.

When to use it

Long pages, so readers see the parts and jump to one: guides, policies, documentation.

When not to

Short pages with one or two headings; SeedPage warns when the table would be empty.

Accessibility

A navigation landmark of links to the page's headings, which get stable addresses. The deep variant also lists the third level.

See it live

The component library shows this component in the default theme, in every variant: open it in the component library

The table of contents example as the component library shows it in the default theme

Where it is used

The starter sites that use it, each at a page that shows it:

Fields

This component has no fields: it takes what it shows from the site.

Variants

A variant changes how the component looks. Write it in parentheses after the name in the table’s first cell, several separated by commas.

Variant

Write in the first cell

Includes subheadings

toc (deep)

In Google Docs

A component is a table. Its first cell names it; the rows below hold its fields. This is the example table:

toc

In a page file

In a site kept as a folder or in Git, the same component is a block of the page’s JSON file:

JSON
{
  "name": "toc",
  "variants": [
    "deep"
  ],
  "rows": []
}

Markup and classes

What the component writes takes these classes, for a theme’s CSS: the component’s own name, name__part for its parts and name--variant for each variant (the variant’s plain name is there too).

Class

What it marks

toc

The component

toc__item

A part of it

toc__item--sub

A part of it

toc__link

A part of it

toc__list

A part of it

toc--deep

A variant

The HTML the example above writes, as the component library builds it in the default theme:

html
<nav class="toc" aria-label="On this page">
<ol class="toc__list">
<li class="toc__item"><a class="toc__link" href="#default">Default</a></li>
<li class="toc__item"><a class="toc__link" href="#includes-subheadings">Includes subheadings</a></li>
<li class="toc__item"><a class="toc__link" href="#table-to-write-in-the-doc">Table to write in the Doc</a></li>
</ol>
</nav>

Visitor texts

Texts it shows visitors, in the page’s language. Every one is in the visitor texts reference.

Key

Text

site.toc.label

On this page

Extending it

Its files in SeedPage. A theme or a site changes the markup by giving a file of the same name (the Liquid part), and a new component can extend this one.

  • src/components/toc.js
  • src/components/toc/toc.liquid