🎨 Color Swatch Plugin for MkDocs
A lightweight plugin that lets you insert inline color swatches into your Markdown docs using a simple, readable syntax.
- 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)
- Hex colors -
- No CSS setup required — styles are embedded automatically
Visit demo: https://fabieu.github.io/mkdocs-color-swatch-plugin/
Install the plugin from PyPI using pip:
pip install mkdocs-color-swatch-pluginThen enable it in your mkdocs.yml:
plugins:
- color-swatchMake sure you have mkdocs installed:
pip install mkdocsTo 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)]: -> BlueEach tag will render as:
- A visual color preview
- Dynamically generated tooltips showing the color value and label
- A smooth hover animation for swatch elements
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.
- 🎨 Works with all valid
hex,rgb(), andrgba()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
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 installpoetry install
pip install -e .This allows you to test your changes directly when running MkDocs locally.
MIT © Fabian Eulitz