Zen Mode toggle for MkDocs Material — distraction-free reading
Project description
mkdocs-zen-mode
Zen Mode for MkDocs Material — distraction-free reading with a single click.
A plugin that adds a Zen Mode toggle to MkDocs Material sites. When activated, it hides the navigation sidebar, table of contents, header, footer, and tabs — leaving only the content centered for comfortable, distraction-free reading.
Features
- Toggle button in the header (next to search)
- Hides navigation, TOC, header, footer, and tabs
- Centers content at a configurable max-width (default: 780px)
- Keyboard shortcut: Alt+Z (configurable)
- State persists across pages and reloads via localStorage
- Works with
navigation.instant(SPA mode) - Smooth CSS transitions
- Floating exit button when header is hidden
- Fully configurable: choose what to hide
- Dark mode compatible
Installation
pip install mkdocs-zen-mode
Quick Start
Add to your mkdocs.yml:
plugins:
- search
- zen-mode
That's it! A toggle button will appear in the header.
Configuration
All options are optional:
plugins:
- zen-mode:
enabled: true # Master switch (default: true)
max_width: "780px" # Content width in zen mode
shortcut: "Alt+Z" # Keyboard shortcut
storage_key: "mkdocs-zen-mode" # localStorage key
button_position: "header" # "header" or "none"
hide_header: true # Hide the top header bar
hide_footer: true # Hide the footer
hide_tabs: true # Hide navigation tabs
hide_toc: true # Hide table of contents (right sidebar)
hide_nav: true # Hide navigation (left sidebar)
transition_duration: "0.3s" # CSS transition speed
Examples
Keep the TOC visible in zen mode:
plugins:
- zen-mode:
hide_toc: false
Use a custom keyboard shortcut:
plugins:
- zen-mode:
shortcut: "Ctrl+Shift+Z"
Only use the keyboard shortcut (no visible button):
plugins:
- zen-mode:
button_position: "none"
Manual Installation (without plugin)
If you prefer not to use the plugin system (or for MkDocs 2.0+), you can manually add the CSS and JS:
- Copy
mkdocs_zen_mode/assets/zen-mode.csstodocs/stylesheets/zen-mode.css - Copy
mkdocs_zen_mode/assets/zen-mode.jstodocs/javascripts/zen-mode.js - Replace the
{{...}}placeholders in both files with your desired values - Add to
mkdocs.yml:
extra_css:
- stylesheets/zen-mode.css
extra_javascript:
- javascripts/zen-mode.js
- Add the toggle button to your
overrides/main.htmlheader block.
Compatibility
- MkDocs Material 9.x (primary target)
- MkDocs >= 1.4
- Degrades gracefully on non-Material themes (keyboard shortcut and FAB still work)
- Python 3.9+
Development
git clone https://github.com/nitaibezerra/mkdocs-zen-mode.git
cd mkdocs-zen-mode
pip install -e ".[dev]"
pytest tests/ -v
License
MIT
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 mkdocs_zen_mode-0.1.0.tar.gz.
File metadata
- Download URL: mkdocs_zen_mode-0.1.0.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d43612c2bba9baf2d4fc9ab28f71aac47e506dd89c131838919fa6fe1a4cfb43
|
|
| MD5 |
c0a8755b03a1fc41ee7888f2d35c1bcd
|
|
| BLAKE2b-256 |
d57f6df2b2a7c6ec7d2bd113f0f37a97181f0daf09a1635d162f0a0200ebb057
|
Provenance
The following attestation bundles were made for mkdocs_zen_mode-0.1.0.tar.gz:
Publisher:
publish.yml on nitaibezerra/mkdocs-zen-mode
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkdocs_zen_mode-0.1.0.tar.gz -
Subject digest:
d43612c2bba9baf2d4fc9ab28f71aac47e506dd89c131838919fa6fe1a4cfb43 - Sigstore transparency entry: 1051753950
- Sigstore integration time:
-
Permalink:
nitaibezerra/mkdocs-zen-mode@9f6cf7f39a56991d97c6e89e85b60a8e1ebe8451 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/nitaibezerra
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9f6cf7f39a56991d97c6e89e85b60a8e1ebe8451 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mkdocs_zen_mode-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mkdocs_zen_mode-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a787d4b159f3036f6397118432dec77fb3f54c0942f7f0d493d549159c7ffa5
|
|
| MD5 |
e96f85229b769392b5ca546d0bec0432
|
|
| BLAKE2b-256 |
6c4a6b1def7d96bc3adbeef3ef33de5991954573870a4183ae5bba5d2d758b1f
|
Provenance
The following attestation bundles were made for mkdocs_zen_mode-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on nitaibezerra/mkdocs-zen-mode
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkdocs_zen_mode-0.1.0-py3-none-any.whl -
Subject digest:
7a787d4b159f3036f6397118432dec77fb3f54c0942f7f0d493d549159c7ffa5 - Sigstore transparency entry: 1051753958
- Sigstore integration time:
-
Permalink:
nitaibezerra/mkdocs-zen-mode@9f6cf7f39a56991d97c6e89e85b60a8e1ebe8451 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/nitaibezerra
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9f6cf7f39a56991d97c6e89e85b60a8e1ebe8451 -
Trigger Event:
push
-
Statement type: