Tabs
Create tabbed content in Sphinx documentation. Perfect for showing code examples in multiple languages.
ui
About this Extension
Creates tabbed interfaces for organizing related content. Commonly used to show the same example in multiple programming languages or different approaches to the same task.
Use cases
- Code examples in multiple programming languages
- Different installation methods (pip, conda, docker)
- Platform-specific instructions (Windows, macOS, Linux)
- Alternative configuration options
- Before/after comparisons
Basic syntax
.. tabs::
.. tab:: Python
.. code-block:: python
print("Hello World")
.. tab:: JavaScript
.. code-block:: javascript
console.log("Hello World");
Advanced features
Group tabs that sync across the page:
.. tabs::
.. group-tab:: Python
Python content here
.. group-tab:: JavaScript
JavaScript content here
When a user clicks “Python” in one tab group, all other tab groups on the page will automatically switch to their “Python” tab.
Configuration
# conf.py
extensions = ['sphinx_tabs']
# Optional: set default tab
sphinx_tabs_default_tab = "python"
Works with any content type - code blocks, text, images, or other directives.