Tabs

Tabs organize and allow navigation between groups of content that are related and at the same level of hierarchy. Each tab should contain content that is distinct from other tabs in a set.

Content 1

Content 2

Syntax
::::{tab-set}

:::{tab-item} Label1
Content 1
:::

:::{tab-item} Label2
Content 2
:::

::::
.. tab-set::

    .. tab-item:: Label1

        Content 1

    .. tab-item:: Label2

        Content 2

See the Material Design description for further details.

Synchronised Tabs

Use the sync option to synchronise the selected tab items across multiple tab-sets. Note, synchronisation requires that JavaScript is enabled.

Content 1

Content 2

Content 1

Content 2

Syntax
::::{tab-set}

:::{tab-item} Label1
:sync: key1

Content 1
:::

:::{tab-item} Label2
:sync: key2

Content 2
:::

::::

::::{tab-set}

:::{tab-item} Label1
:sync: key1

Content 1
:::

:::{tab-item} Label2
:sync: key2

Content 2
:::

::::
.. tab-set::

    .. tab-item:: Label1
        :sync: key1

        Content 1

    .. tab-item:: Label2
        :sync: key2

        Content 2

.. tab-set::

    .. tab-item:: Label1
        :sync: key1

        Content 1

    .. tab-item:: Label2
        :sync: key2

        Content 2

Tabbed code examples

The tab-set-code directive provides a shorthand for synced code examples. You can place any directives in a tab-set-code that produce a literal_block node with a language attribute, for example code, code-block and literalinclude. Tabs will be labelled and synchronised by the language attribute (in upper-case).

````{tab-set-code}

```{literalinclude} ./snippet.py
:language: python
```

```{code-block} javascript
a = 1;
```

````
.. tab-set-code::

    .. literalinclude:: ./snippet.py
        :language: python

    .. code-block:: javascript

        a = 1;

Tabs in other components

Tabs can be nested inside other components, such as inside dropdowns or within grid items.

Tabs in dropdown

Paragraph

Content 1

Content 2

Initial paragraph

Content 1

Content 2

Content 1

Content 2

Ending paragraph

Tab set, within tab set:

Content 1a

Content 1b

Content 2

tab-set options

class

Additional CSS classes for the container element.

tab-item options

selected

a flag indicating whether the tab should be selected by default.

sync

A key that is used to sync the selected tab across multiple tab-sets.

name

Set a reference-able name for the dropdown container.

class-container

Additional CSS classes for the container element.

class-label

Additional CSS classes for the label element.

class-content

Additional CSS classes for the content element.