Sphinx RTD Dark Mode

1.3.0 · active · verified Thu Apr 16

sphinx-rtd-dark-mode is a Sphinx extension that adds a toggleable dark mode to the Read the Docs Sphinx theme. Currently at version 1.3.0, it receives periodic updates to enhance styling, fix visual bugs across various Sphinx elements, and improve user experience.

Common errors

Warnings

Install

Imports

Quickstart

To enable sphinx-rtd-dark-mode, first ensure you have `sphinx` and `sphinx-rtd-theme` installed. Then, add `'sphinx_rtd_dark_mode'` to the `extensions` list in your `conf.py` file. Optionally, set `default_dark_mode = False` if you prefer the light theme on the first load.

# conf.py

import os
import sys
# Add your project's path if necessary
# sys.path.insert(0, os.path.abspath('.'))

project = 'My Project'
copyright = '2026, Your Name'
author = 'Your Name'
version = '0.1'
release = '0.1.0'

html_theme = 'sphinx_rtd_theme'
extensions = [
    'sphinx_rtd_dark_mode',
]

# Optional: Set the default mode (True for dark, False for light)
default_dark_mode = True

# To build:
# sphinx-build -b html . _build

view raw JSON →