Table of contents
The headings of the current page, in the margin, with a mark on the heading that you are at. It works like Tabs turned vertical: a list of places where exactly one is current. Text colour and a line mark the current heading, never a fill. A fill would make it a row that you pick from a list, and the sidebar on the other side of the page is already that. The entries draw the line themselves, with no measured indicator under them. Thus the lit segment is exactly the entry that it marks, and nothing must stay in sync. Sub-headings start further in, and they do not use a third text colour. If you do not control it, it watches the page with an IntersectionObserver and marks the last heading that you passed. A simple spelling that marks the top visible heading shows nothing in that case. If you give it a `current` value, it marks that heading. It does not decide the column. The width, the sticky position and the window width at which two columns no longer fit are part of the page layout. They come from the class that you pass in.
import { TableOfContents } from "../../blocks/table-of-contents";export default function Example() { return ( <TableOfContents entries={[ { id: "installing", title: "Installing", level: 2 }, { id: "the-theme", title: "The theme", level: 2 }, { id: "appearance", title: "Appearance", level: 3 }, { id: "density", title: "Density", level: 3 }, { id: "next-steps", title: "Next steps", level: 2 }, ]} current="the-theme" /> );}