Skip to content
npm ↗ GitHub ↗

Documentation

07/Structure

Documentation sidebar

Side navigation with groups, active link, version selector and a table of contents that follows the scroll.

Table of contents

With data-cb-scrollspy the link of the visible section is marked automatically. It's the right column on this page.

HTML
<nav class="cb-toc" aria-label="En esta página" data-cb-scrollspy>
  <p class="cb-toc__title">En esta página</p>
  <a class="cb-toc__link" href="#sidebar">Sidebar</a>
  <a class="cb-toc__link" href="#tabla-de-contenidos">Tabla de contenidos</a>
</nav>

Classes and modifiers

ClassDescription
.cb-sidenavColumn of groups. --sticky pins it while scrolling.
.cb-sidenav__versionVersion selector row.
.cb-sidenav__group, .cb-sidenav__title, .cb-sidenav__listGroup, title and list.
.cb-sidenav__linkLink with a left line; aria-current="page" marks it.
.cb-sidenav__badgeSmall badge in the accent color.
.cb-toc, .cb-toc__linkPage table of contents.

data-cb-* attributes

AttributeDescription
data-cb-scrollspyMarks the link whose section is on screen.
data-cb-version-selectWhen the select changes, it navigates to the URL in its value.

JavaScript

EventWhen it fires
cb:changeOn the nav with scrollspy when the active section changes (detail.id).

Accessibility

  • The current page uses aria-current="page"; the active section uses aria-current="true".
  • The version select needs a label, even if it's cb-sr-only.