diff --git a/docs/user_guide/configuring.rst b/docs/user_guide/configuring.rst index 56f4e41d0..d4f6b9ff8 100644 --- a/docs/user_guide/configuring.rst +++ b/docs/user_guide/configuring.rst @@ -386,6 +386,9 @@ each can have the following fields: switcher. - ``name``: an optional name to display in the switcher dropdown instead of the version string (e.g., "latest", "stable", "dev", etc). +- ``extra_classes``: an optional list of classes to add to the switcher + button for a given version (e.g., ``["dev", "rc"]``). These classes are only + added when the version is active. - ``url``: an optional URL. If provided, it links the version to ``url`` instead of ``switcher['url_template']``. @@ -398,6 +401,10 @@ Here is an example JSON file: "name": "v2.1 (stable)", "version": "2.1" }, + { + "version": "2.1rc1", + "extra_classes": ["dev", "rc"] + }, { "version": "2.0" }, diff --git a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/_templates/version-switcher.html b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/_templates/version-switcher.html index 9f310f7b4..ff6ee4544 100644 --- a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/_templates/version-switcher.html +++ b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/_templates/version-switcher.html @@ -74,6 +74,10 @@ if (entry.version == "{{ theme_switcher.get('version_match') }}") { node.classList.add("active"); $("#version_switcher_button").text(entry.name); + // Add extra class to the button for the selected entry + if ("extra_classes" in entry) { + $("#version_switcher_menu").classList.add(...entry.extra_classes); + } } }); });