07/Structure
Documentation sidebar
Side navigation with groups, active link, version selector and a table of contents that follows the scroll.
Sidebar
HTML
<nav class="cb-sidenav max-w-[260px]" aria-label="Documentación">
<div class="cb-sidenav__version">
<div class="cb-select"><select class="cb-input cb-input--sm" aria-label="Versión"><option>v2.1 (actual)</option><option>v1.4</option></select></div>
</div>
<div class="cb-sidenav__group">
<p class="cb-sidenav__title">Empezar</p>
<ul class="cb-sidenav__list">
<li><a class="cb-sidenav__link" href="#">Introducción</a></li>
<li><a class="cb-sidenav__link" href="#" aria-current="page">Instalación</a></li>
<li><a class="cb-sidenav__link" href="#">Temas <span class="cb-sidenav__badge">Nuevo</span></a></li>
</ul>
</div>
</nav>
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
| Class | Description |
|---|---|
.cb-sidenav | Column of groups. --sticky pins it while scrolling. |
.cb-sidenav__version | Version selector row. |
.cb-sidenav__group, .cb-sidenav__title, .cb-sidenav__list | Group, title and list. |
.cb-sidenav__link | Link with a left line; aria-current="page" marks it. |
.cb-sidenav__badge | Small badge in the accent color. |
.cb-toc, .cb-toc__link | Page table of contents. |
data-cb-* attributes
| Attribute | Description |
|---|---|
data-cb-scrollspy | Marks the link whose section is on screen. |
data-cb-version-select | When the select changes, it navigates to the URL in its value. |
JavaScript
| Event | When it fires |
|---|---|
cb:change | On the nav with scrollspy when the active section changes (detail.id). |
Accessibility
- The current page uses
aria-current="page"; the active section usesaria-current="true". - The version
selectneeds a label, even if it'scb-sr-only.