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)
      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.0.tar.gz (14.6 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.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

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

Hashes for mkdocs_zen_mode-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d43612c2bba9baf2d4fc9ab28f71aac47e506dd89c131838919fa6fe1a4cfb43
MD5 c0a8755b03a1fc41ee7888f2d35c1bcd
BLAKE2b-256 d57f6df2b2a7c6ec7d2bd113f0f37a97181f0daf09a1635d162f0a0200ebb057

See more details on using hashes here.

Provenance

The following attestation bundles were made for mkdocs_zen_mode-0.1.0.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.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_zen_mode-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a787d4b159f3036f6397118432dec77fb3f54c0942f7f0d493d549159c7ffa5
MD5 e96f85229b769392b5ca546d0bec0432
BLAKE2b-256 6c4a6b1def7d96bc3adbeef3ef33de5991954573870a4183ae5bba5d2d758b1f

See more details on using hashes here.

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

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