Skip to main content

A MkDocs plugin for inline color swatches with tooltip and hover effects

Project description

🎨 Color Swatch Plugin for MkDocs

A lightweight plugin that lets you insert inline color swatches into your Markdown docs using a simple, readable syntax.

PyPI PyPI - Python Version GitHub pipeline status GitHub issues GitHub merge requests GitHub

⭐ Features

  • Styled swatches with smooth hover animations and tooltips
  • Responsive swatches for all screen sizes
  • Supports various color formats:
    • Hex colors - #ff0000/#f00
    • RGB colors - rgb(255, 0, 0)
    • RGBA colors - rgba(255, 0, 0, 0.5)
  • No CSS setup required — styles are embedded automatically

Visit demo: https://fabieu.github.io/mkdocs-color-swatch-plugin/


🚀 Installation

Prerequisites

Install the plugin from PyPI using pip:

pip install mkdocs-color-swatch-plugin

Then enable it in your mkdocs.yml:

plugins:
  - color-swatch

Make sure you have mkdocs installed:

pip install mkdocs

✍️ Syntax & Usage

To add swatches to your Markdown, use the simple, custom inline format:

:color[#e74c3c]: -> Red
:color[rgb(52, 152, 219)]: -> Green
:color[rgba(46, 204, 113, 0.6)]: -> Blue

Each tag will render as:

  • A visual color preview
  • Dynamically generated tooltips showing the color value and label
  • A smooth hover animation for swatch elements

🧠 Why Use This Plugin?

Instead of manually writing HTML for every color sample like:

<span style="background-color: #e74c3c; width: 30px; height: 30px; ..."></span>

You can just write:

:color[#e74c3c]:  

It's faster, cleaner, and scales dynamically with your content.


💡 Features & Benefits

  • 🎨 Works with all valid hex, rgb(), and rgba() color values
  • 🎯 Simple syntax for embedding colors directly in your Markdown files
  • 🛠 Automatically injected CSS for responsive and visually appealing swatches
  • 🔄 Perfectly safe to use with other Markdown extensions
  • 🔍 Live color preview in rendered HTML files, complete with tooltips

🛠 Development & Contribution

👨‍💻 Repository Setup:

Clone the project repository and configure the environment with Poetry:

git clone https://github.com/yourusername/mkdocs-color-swatch-plugin.git
cd mkdocs-color-swatch-plugin
poetry install

Editable Install (for local use):

poetry install
pip install -e .

This allows you to test your changes directly when running MkDocs locally.


📄 License

MIT © Fabian Eulitz


📎 Resources

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_color_swatch_plugin-0.2.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

mkdocs_color_swatch_plugin-0.2.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs_color_swatch_plugin-0.2.0.tar.gz.

File metadata

  • Download URL: mkdocs_color_swatch_plugin-0.2.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.3 Linux/6.8.0-1021-azure

File hashes

Hashes for mkdocs_color_swatch_plugin-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5e88d809bc31d8621c833aa7994dc0764278d5d3f93f1d673b4926b37c43ec38
MD5 431cfea31aa752dc26d9ce6779f6474e
BLAKE2b-256 5323118e37b015e90e4e83e8843e283b149e7bb4cc56c3769748cddb87342292

See more details on using hashes here.

File details

Details for the file mkdocs_color_swatch_plugin-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_color_swatch_plugin-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0798d28b3963b30911e54434a91f4f854edf5cbcfd0277cccc450e0ad62f7068
MD5 04a76acc50b9ecd69f87d3a5a68c6cdd
BLAKE2b-256 4dd59e55c3bc5200c40a36388e69d6b09a461ceb2897e8e4696d856b0ac66039

See more details on using hashes here.

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