Skip to main content

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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swagger_theme_toggle-0.1.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swagger_theme_toggle-0.1.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file swagger_theme_toggle-0.1.0.tar.gz.

File metadata

  • Download URL: swagger_theme_toggle-0.1.0.tar.gz
  • Upload date:
  • Size: 8.4 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

Hashes for swagger_theme_toggle-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c8aab3d36836fd2ce404243142990f4cbdb5f336210816dead4804394e1b49b1
MD5 d3db15b0e5180b9c6bd330eec5e56db2
BLAKE2b-256 eb0a161219a66b505257436a060068b2a9a3e92af009c171632367a473c085dc

See more details on using hashes here.

File details

Details for the file swagger_theme_toggle-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: swagger_theme_toggle-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 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

Hashes for swagger_theme_toggle-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4a628c2a5bff9950fe64aeee644456d6bef6ffb27ed426e252178f4d2b7c0293
MD5 204561319acf74e4b45d94aa67efc356
BLAKE2b-256 08838a028572471af4315eac5d40e38f9aa00c8a001446535043f6feb993f586

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page