Import
import { TableOfContents } from '@k8ordo/ui';Usage
Pass the headings as a tree of { id, label, children? }. The contents below point at this page’s own headings, so the current one moves as you scroll.
<TableOfContents
items={[
{ id: 'import', label: 'Import' },
{
id: 'usage',
label: 'Usage',
children: [{ id: 'active', label: 'How the current heading is chosen' }],
},
{ id: 'props', label: 'Props' },
]}
/>How the current heading is chosen
The current heading is the last one whose scroll-margin-block-start position has scrolled past the top. Give the headings the scroll margin your sticky header needs, and a heading reached from the contents becomes current. At the end of the document the last heading is current even if its section is short. A vertical document is read in its own direction: right to left for vertical-rl, left to right for vertical-lr.
Props
items- Type:
readonly TableOfContentsItem[] - Default: -
label?- Type:
string - Default: -
| Prop | Type | Default |
|---|---|---|
items | readonly TableOfContentsItem[] | - |
label? | string | - |
Inherited attributes (except the ones set internally): HTMLAttributes<HTMLElement>
The wording this component draws (labels, placeholders, and so on) comes from the message dictionary unless a prop sets it. To replace it, see: i18n