Light / dark / system theme toggle for FastAPI's Swagger UI docs page
Project description
swagger-theme-toggle
Adds a Light / Dark / Auto theme toggle to FastAPI's Swagger UI docs page.
Install
pip install swagger-theme-toggle
# or
uv add swagger-theme-toggle
Usage
from fastapi import FastAPI
from swagger_theme_toggle import add_dark_mode_toggle
app = FastAPI()
# ... register your routes ...
add_dark_mode_toggle(app)
Call add_dark_mode_toggle last, after your routes and app settings (title,
openapi_url) are finalized — it snapshots them to build the replacement
/docs route.
Options
add_dark_mode_toggle(
app,
docs_url="/docs", # where to mount the docs page
default_theme="system", # "light" | "dark" | "system"
)
The chosen theme is persisted in the browser's localStorage, so it survives
reloads. "system" follows the OS prefers-color-scheme.
Development
uv sync
uv run pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swagger_theme_toggle-0.1.1.tar.gz.
File metadata
- Download URL: swagger_theme_toggle-0.1.1.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1787b96b08754450c8a23380bfeb81cd7d34e41e4fce70c992ba1f919442c9c5
|
|
| MD5 |
8da8e8d2740977d83b029281d01509ee
|
|
| BLAKE2b-256 |
2cc218312e25a570c3c80beb2a950c026047a2d956bd3b65f809f7e6d3cf568e
|
File details
Details for the file swagger_theme_toggle-0.1.1-py3-none-any.whl.
File metadata
- Download URL: swagger_theme_toggle-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e32414a6e50df0b7d76ade020fd644c1aa6e405ed9110a4220742c862e94a1c3
|
|
| MD5 |
a4a9f0c7d705c3870ba85655e3a56da0
|
|
| BLAKE2b-256 |
feec3fd30d3381c22cd7ba36c873f6c7ea92740e088ba9055ab3a229ac87e62f
|