ValyroUI Русская версия

Article Toc

Article table of contents that tracks the current section. Pro · Content and social › Reading and author

Installation

npx valyro-cli@latest login
npx valyro-cli@latest add article-toc
npm install valyro-ui-pro

import 'valyro-ui-pro/styles.css';
import { ArticleToc } from 'valyro-ui-pro';

Props

PropTypeDefault
items *ArticleTocItem[]Headings of the article, in reading order.
activeIdstringSection being read (controlled).
defaultActiveIdstringInitial section when uncontrolled.
onActiveIdChange(id: string) => voidCalled when scrolling reaches another section or a link is followed.
trackbooleantrueFollow the scroll position and mark the section being read (default true).
offsetnumber96Distance in px from the top of the viewport (or container) at which a heading counts as reached (default 96, below a sticky header).
containerRefObject<HTMLElement | null>Scrolling element that holds the article, when it is not the window (a reader pane, a modal).
updateHashbooleantruePut the section's #id in the address on click (default true), so it can be copied and shared. Turn it off in apps whose router reads the hash.
smoothbooleantrueScroll smoothly to the section on click (default true; off when the reader prefers reduced motion).
headingLevel1 | 2 | 3 | 4 | 5 | 62Level of the title (default 2).
collapsiblebooleanfalseFold the list under its title, a native disclosure that starts closed: for contents placed above the text on a phone rather than beside it.
labelsPartial<ArticleTocLabels>Overrides for the built-in English text; keys left out keep their defaults.

Related components

  • Reading Progress — Reading progress bar
  • Share Bar — Share: Telegram, VK, X, WhatsApp, email and copy link
  • Author Bio — Author card at the end of an article, with a follow button
  • Article Header — Article header: section, headline, lede, authors and date
  • Byline — Byline: authors, published and updated dates, reading time
  • Article Figure — Image with caption and photo credit
  • Pull Quote — Pull quote with attribution
  • Key Points — “Key points” summary block
  • Editor Note — Update, correction, disclosure and sponsored-content notes
  • Article Card — News card: vertical, horizontal and over a photo
  • Live Blog — Live blog: update feed, pinned and key events
  • Breaking News — “Breaking” banner with rotating headlines

Previous: Editor Note · Next: Reading Progress · All Content and social