Usage Examples¶
Examples¶
This example shows the basic filter-tabs and tab syntax.
Using ARIA Labels for Better Accessibility¶
Use :aria-label: when a short visible tab name needs more context for
screen reader users.
The :aria-label: option does not change the visible tab labels or the
visible legend above the tabs. It is added to each tab’s hidden radio input, so
assistive technology can announce a more descriptive control name than the
short label shown on screen.
In the example below, the visible legend is still generated automatically from
the tab names. CLI and GUI match the built-in interface category, so
the extension renders the legend as Choose interface: CLI, GUI. The
(default) marker only selects the initially active tab; it is removed from
the visible tab name before the legend is generated.
Providing a Custom Legend¶
By default, the extension creates a visible legend from the tab names. For
example, tabs named Staging and Production match the built-in
environment category and would produce Choose environment: Staging,
Production.
When that generated text is not the clearest label for the group, provide an
explicit visible legend with the :legend: option. This is different from
:aria-label:: :legend: changes the visible group label for everyone,
while :aria-label: changes the accessible name of an individual hidden tab
control.
Source Code for Custom Legend¶
The following RST markup was used to create the above example:
.. filter-tabs:: :legend: Select Your Deployment Environment .. tab:: Staging (default) This panel shows configuration for the **staging** environment. It's used for testing before release. .. tab:: Production This panel shows configuration for the **production** environment. This is the live, user-facing setup.
Hiding the Visible Legend¶
Some pages already introduce the tab context in nearby prose or headings. In
those cases, add :hide-legend: to keep the tab group visually compact while
preserving the semantic <legend> for assistive technology.
Nested Tabs¶
You can nest filter-tabs directives to create more complex layouts.
Indent the inner tab group inside a tab directive of the outer group.
Large Tab Groups¶
There is no fixed 10-tab limit. The panel-visibility CSS is generated at build time and scales to the tab groups used in each build. The following example shows 12 tabs, which is realistic for a library that ships official clients for many languages.
Note
Tab groups above 15 will trigger a build warning encouraging you to
consider restructuring. The generated CSS scales to the largest tab group
in the build, but for truly large sets of alternatives a toctree
or a comparison table is usually a better fit.
pip install acme-client
npm install acme-client
npm install acme-client
# Type declarations are bundled; no @types package needed.
go get github.com/acme/acme-client-go
# Cargo.toml
[dependencies]
acme-client = "1.0"
<!-- pom.xml -->
<dependency>
<groupId>com.acme</groupId>
<artifactId>acme-client</artifactId>
<version>1.0.0</version>
</dependency>
// build.gradle.kts
implementation("com.acme:acme-client:1.0.0")
dotnet add package Acme.Client
gem install acme-client
composer require acme/acme-client
// Package.swift
.package(url: "https://github.com/acme/acme-client-swift", from: "1.0.0")
# mix.exs
{:acme_client, "~> 1.0"}