darkdetect
Detect OS Dark Mode from Python
What it is and what it does
Darkdetect is a lightweight, dependency-free library that queries the operating system to determine whether Dark Mode is currently active. It works on macOS 10.14+, Windows 10 1607+, and Linux systems with dark GTK themes, returning a simple boolean or string indicating the current theme. The package is designed for GUI application developers who need to adapt their interface colors to match the system theme, particularly when their GUI framework does not expose a native dark mode detection API.
The library provides three main functions: `theme()` returns the string 'Dark' or 'Light', `isDark()` and `isLight()` return booleans. It also offers a `listener()` function that runs as a daemon thread to monitor for OS theme changes and invoke a callback when the user switches modes. Because it has no external dependencies beyond the Python standard library, it can be vendored directly into applications if needed.
Use it for:
- Adapt a Tkinter, wxPython, or PyQt GUI to match the system dark mode without relying on the GUI framework's own detection API.
- Monitor for live theme switches and update application colors in real time via a background listener thread.
- Conditionally load light or dark stylesheets or color palettes at application startup based on the current OS theme.
- Build cross-platform desktop tools that respect user accessibility and appearance preferences on macOS, Windows, and Linux.
- Vendor darkdetect into a standalone application to avoid external package dependencies while still supporting dark mode detection.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Detects whether the operating system is in Dark Mode on macOS 10.14+, Windows 10 1607+, and Linux with dark GTK themes, and optionally monitors for theme changes.
Yes, if you are building a GUI application on macOS, Windows, or Linux and need to detect or respond to the system dark mode. The package is lightweight, has no dependencies, and solves a real problem for frameworks that do not expose dark mode detection. Maintenance is dormant but the package is stable and has no known vulnerabilities; install it as a utility library rather than expecting active development.
Install
darkdetect on PyPI
pip
pip install darkdetectuv
uv add darkdetectpoetry
poetry add darkdetectInstalling darkdetect
Before you install
Low friction: pure Python wheel with no runtime dependencies. Maintenance is dormant (last commit 2024-03-11, 1337 days since release), but the package is stable and archived status is false.
License in practice
BSD-3-Clause is permissive; you may use, modify, and distribute this package freely in commercial or open-source projects provided you include the license notice.
Quickstart
pip install darkdetect
import darkdetect
if darkdetect.isDark():
print('Dark mode is active')
else:
print('Light mode is active')
Verify before relying
- Whether the macOS listener (optional install darkdetect[macos-listener]) requires additional system libraries or frameworks beyond what the base package provides.
- Exact behavior and return values when run on unsupported OS versions or systems without dark mode support (documentation states it returns None but does not specify all edge cases).
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 1,337 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,369,936/month — #3,994 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: darkdetect-0.8.0-py3-none-any.whl
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
sv-ttkApplies a modern, Windows 11-inspired visual…
permissive · top 15,000 on PyPI
st-themeDetects and returns the active theme (light or…
permissive · top 15,000 on PyPI
QDarkStyleQDarkStyle provides pre-built dark and light…
permissive · top 15,000 on PyPI
sphinx-rtd-dark-modeAdds a toggleable dark mode interface to Sphinx…
permissive · top 15,000 on PyPI
ttkbootstrapApplies Bootstrap-inspired themes and a…
permissive · top 15,000 on PyPI
qt-materialApplies a Material Design stylesheet to PySide6…
permissive · top 15,000 on PyPI
desktop-notifierSends cross-platform desktop notifications from…
permissive · top 15,000 on PyPI
notify2notify2 creates and displays desktop…
permissive · top 15,000 on PyPI
colorclassProvides ANSI color text output for console…
permissive · top 5,000 on PyPI
detect-installerDetects which package manager installed a given…
permissive · top 5,000 on PyPI