Skip to main content
brickwork
GitHub Log in Get started
Display
Theme
Density
Direction
Brand

Documentation

Toc

A documentation “On this page” navigation.

All components Component Brickwork 4.3.1

Try it

Article outline

Open full-page preview

Active child section.

Use with a consumer-authored heading outline.

Use it

Working invocation

This code creates the configuration shown above. Copy the template and the required Python context together.

templates/your_app/component.html

Django template

{% load brickwork_components %}
{% bw_toc items=toc_items active=active %}

your_app/views.py

Python

context = {'toc_items': [{'label': 'Installation', 'href': '#install'}, {'label': 'Reference', 'href': '#reference', 'children': [{'label': 'Options', 'href': '#options'}]}], 'active': 'options'}

Guide

Add it to your project

  1. Load `brickwork_components`.
  2. Prefer `bw_toc` to validate item shape and active target.

View this component's source for the installed release

Options

Public API

Option Type Default Required Description
items list of mappings Not set Yes label and href; optional one level of children. Constraint: Each item must follow the component's documented item-record shape; keep labels and destinations paired.
active string Empty string No Href or bare id to mark current. Constraint: Must match an identifier declared by the corresponding structured collection.
heading string On this page No Visible landmark heading. Constraint: No additional package-level validation is documented beyond this option's stated type and its role in the component.
heading_id string bw-toc-heading No Heading id. Constraint: No additional package-level validation is documented beyond this option's stated type and its role in the component.

Behaviour

Accessibility and responsive behaviour

Accessibility
A labelled nav gives `aria-current=location` to the active item.
Responsive
Inherits docs TOC measure.
Without JavaScript
Normal in-page links.

Need help?

Troubleshooting

Contract check: nothing (no empty landmark).

Supply a non-empty, correctly shaped item list when a contents landmark is needed; empty input intentionally emits no landmark.

Explore next

Used in examples

Documentation