Version switch
A documentation-version navigation switcher.
Try it
Versioned docs
Current stable release.
Use it
Working invocation
This code creates the configuration shown above. Copy the template and the required Python context together.
{% load brickwork_components %}
{% bw_version_switch versions=versions current=current placement=placement %}
context = {'versions': [{'label': '4.2', 'href': '/docs/4.2/components/', 'status': 'latest'}, {'label': '4.1', 'href': '/docs/4.1/components/', 'status': 'deprecated'}], 'current': '4.2', 'placement': 'end'}
Guide
Add it to your project
- Load `brickwork_components`.
- Call `bw_version_switch` with versions and the label of exactly one current version.
Options
Public API
| Option | Type | Default | Required | Description |
|---|---|---|---|---|
| versions | list of mappings | Not set | Yes | Each requires label and href; optional status. Allowed: latest, deprecated. Constraint: Each version record needs an identifier, label, and valid destination; `current` must match one identifier. |
| current | string | Not set | Yes | Must match exactly one version label. Constraint: Must match an identifier declared by the corresponding structured collection. |
| label | string | Documentation version | No | Navigation landmark name. Constraint: Use concise visible text that identifies the control or measurement. |
| placement | string | start | No | Panel edge. Allowed: start, end. Constraint: Use only one of the documented logical or physical placement choices. |
Behaviour
Accessibility and responsive behaviour
- Accessibility
- Native nav labels current version with `aria-current`; statuses are text, not colour-only.
- Responsive
- Fluid inside docs header.
- Without JavaScript
- Native details/summary and ordinary links require no JavaScript.
Need help?
Troubleshooting
Contract check: tag enforces a non-empty versions list, a current= that matches exactly one
Use the version-switch tag with a non-empty versions list and a `current` value matching exactly one version.
Explore next