Skip to main content

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.

PyPI version License: MIT

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)
      hide_announce: true        # Hide the announce bar
      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:

  1. Copy mkdocs_zen_mode/assets/zen-mode.css to docs/stylesheets/zen-mode.css
  2. Copy mkdocs_zen_mode/assets/zen-mode.js to docs/javascripts/zen-mode.js
  3. Replace the {{...}} placeholders in both files with your desired values
  4. Add to mkdocs.yml:
extra_css:
  - stylesheets/zen-mode.css
extra_javascript:
  - javascripts/zen-mode.js
  1. Add the toggle button to your overrides/main.html header 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


Download files

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

Source Distribution

mkdocs_zen_mode-0.1.1.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

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

mkdocs_zen_mode-0.1.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs_zen_mode-0.1.1.tar.gz.

File metadata

  • Download URL: mkdocs_zen_mode-0.1.1.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mkdocs_zen_mode-0.1.1.tar.gz
Algorithm Hash digest
SHA256 41177aa1da57f4685653dd4a9c39ede971a0c02303d7add310e708463cc1b8ee
MD5 2c486a5b30da4b1218bb5eef0f4e6be5
BLAKE2b-256 d9f39721e58947b27a06f658b4c1571b19821255e1df643eac4254b9f437e078

See more details on using hashes here.

Provenance

The following attestation bundles were made for mkdocs_zen_mode-0.1.1.tar.gz:

Publisher: publish.yml on nitaibezerra/mkdocs-zen-mode

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mkdocs_zen_mode-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_zen_mode-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b1d35355cf7616148b185fc4c7ffc20f2111abeafb51998c7be85213b06f2c1f
MD5 33915c2c58f5009698ae9cd1ff4f32b6
BLAKE2b-256 71f388b024ae8f2f234d2a95ec4b1f24300534bcbe0a5abf65ae2d45db46dfcf

See more details on using hashes here.

Provenance

The following attestation bundles were made for mkdocs_zen_mode-0.1.1-py3-none-any.whl:

Publisher: publish.yml on nitaibezerra/mkdocs-zen-mode

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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