Skip to main content

sphinx-togglebutton

A small sphinx extension to make it possible to add a "toggle button" to sections of your page. This allows you to:

  • Collapse Sphinx admonitions (notes, warnings, etc) so that their content is hidden until users click a toggle button.
  • Collapse arbitrary chunks of content on your page with a collapse directive.

Demonstration of Sphinx Togglebutton

Installation

You can install sphinx-togglebutton with pip:

pip install sphinx-togglebutton

Usage

In your conf.py configuration file, add sphinx_togglebutton to your extensions list.

E.g.:

extensions = [
    ...
    'sphinx_togglebutton'
    ...
]

Now, whenever you wish for an admonition to be toggle-able, add the :class: dropdown parameter to the admonition directive that you use.

For example, this code would create a toggle-able "note" admonition that starts hidden:

.. note::
    :class: dropdown

    This is my note.

Clicking on the toggle button will toggle the item's visibility.

You may also show the content by default. To do so, add the dropdown class as well as a toggle-shown class, like so:

.. note::
    :class: dropdown, toggle-shown

    This is my note.

You can also use containers to add arbitrary toggle-able code. For example, here's a container with an image inside:

.. container:: toggle, toggle-hidden

    .. admonition:: Look at that, an image!

        .. image:: https://media.giphy.com/media/mW05nwEyXLP0Y/giphy.gif

Internationalization (i18n)

The texts Click to hide and Click to show used in the toggle buttons are internationalized by using the set language from Sphinx's configuration.

Supported languages are English (default), Chinese (Simplified), Chinese (Traditional), Hindi, Spanish, French, Arabic, Bengali, Russian, Portuguese, Indonesian, Japanese, German, Korean, Turkish, Vietnamese, Tamil, Italian, Thai, Dutch, Greek, Polish, Ukrainian, Persian, Malay, Swahili, Romanian, Czech, Hungarian, Hebrew, Swedish, and Norwegian.

Release files for sphinx-togglebutton 0.4.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sphinx-togglebutton 0.4.5
File Size Uploaded
sphinx_togglebutton-0.4.5.tar.gz 18.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sphinx-togglebutton 0.4.5
File Interpreter ABI Platform
sphinx_togglebutton-0.4.5-py3-none-any.whl Python 3 none any Details

Total release size: 63.0 kB

Release files / sphinx_togglebutton-0.4.5.tar.gz

Download URL sphinx_togglebutton-0.4.5.tar.gz
Size 18.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c870dfbd3bc6e119b50ff9a37a64f8991902269e856728931c7d89877e8d4b3d
BLAKE2b-256 checksum
How to use checksums
ccbe169a0b0a8ad9588e8697c85e1d489aaaca7416073c2fc0267c360af5aae9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / sphinx_togglebutton-0.4.5-py3-none-any.whl

Download URL sphinx_togglebutton-0.4.5-py3-none-any.whl
Size 44.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
74eac6d2426110c3e1e6f989a98e07d7823141a335df1ad8a9d637bdf6a7af62
BLAKE2b-256 checksum
How to use checksums
d82e3dd55564928c5d61f92827d4b91307dde7911a40fbe0000645d73202eea9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.4.5 This release

2 release files

0.4.4

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page