import {Toc} from '@gravity-ui/uikit';

The Toc component is designed to display a table of contents of the page, namely showing a set items with two levels of hierarchy.

Usage

You can use Toc in two ways:

  1. With items as links.
  2. With items as clickable buttons.

To use the first option, provide the appropriate link to each Toc item through the href property. You will still be able to use a click handler to control the active Toc element.

If you skip this, the component will use the other option.

Properties

NameDescriptionTypeDefault
classNameCSS classstring
itemsTOC elementsTocItem[]
valueCurrent active itemstring
onUpdateItem click handlerFunction
qaThe value to provide to the data-qa attribute of the Toc containerstring

TocItem

NameDescriptionTypeDefault
valueItem valuestring
contentItem content to displayReact.ReactNode[]
hrefThe href property of the <a> element, to which an item will be converted if providedstring
itemsChild itemsTocItem[]