Skip to main content
Urbicon UI
source

TableOfContents

Sticky sidebar navigation that tracks scroll position and highlights the active section. Hidden on mobile — DocsLayout provides the collapsible alternative there.

Playground

Introduction

Content

Setup

Content

Usage

Content
Position
Width
<TableOfContents />

01 Examples

Page navigation

Basic Usage

<TableOfContents
  navigation={[
    { id: 'overview', title: 'Overview' },
    { id: 'api', title: 'API' }
  ]}
/>

02 Accessibility

Named landmarks, because there are several

The component renders an <aside> holding one to three <nav> elements — sections, related pages, and the code toggle block. Every one of them is labelled, because a documentation page already carries a handful of asides and navigations and an unnamed one is a stop that announces nothing.

aria-current is location, not page

The active entry points at a section of the page the reader is already on, so it carries aria-current="location". page would claim it links to the current document, which is what the sidebar's entry for this page does.

Scroll-spy marks, it does not move focus

Scrolling only changes which entry is marked. Focus stays where the reader left it — the alternative, dragging focus along with the scroll position, would make the page unusable with a keyboard.

Only the kickers are tagged with a language

"On this page", "Related" and the toggle label come from the docs translations and carry a lang of their own; the entry labels do not, because they are the page's section titles and are written in the content language. Tagging the whole aside would declare those titles as the chrome locale — a worse mismatch than the three kicker words it would fix.

Hidden below the sidebar breakpoint

The component is display-hidden on narrow viewports rather than reflowed, so it is out of the reading order there as well as out of sight. DocsLayout renders its own collapsible table of contents for that case — a page that uses this component standalone has to provide the small-screen path itself.

03 API Reference

Complete list of component properties and their configurations

12 props 1 required
Prop
Type
Default
Description

04 Types

Local type definitions used by this component.

5 types
Name
Kind
Category
Used by
Description

05 Installation

Import

import { TableOfContents } from '@urbicon-ui/docs';