How to Customize Colors¶
This guide shows you how to customize the color scheme of your MkDocs Material documentation site.
Change Primary and Accent Colors¶
To change the primary and accent colors in mkdocs.yml:
- Open
mkdocs.ymlin your editor - Locate the
theme.palettesection - Modify the
primaryandaccentvalues:
Available colors: red, pink, purple, deep purple, indigo, blue, light blue, cyan, teal, green, light green, lime, yellow, amber, orange, deep orange, brown, grey, blue grey, black, white.
Use Custom Colors with CSS¶
For more control, use custom CSS with specific color codes:
- Create
docs/stylesheets/extra.css(if it doesn't exist) - Add your custom colors:
[data-md-color-scheme="default"] {
--md-primary-fg-color: #74c7ec; /* Your custom color */
--md-accent-fg-color: #89b4fa; /* Your custom accent */
}
- Reference it in
mkdocs.yml:
Apply Catppuccin Color Scheme¶
To use the Catppuccin Mocha palette:
- Add to your
docs/stylesheets/extra.css:
/* Light mode */
[data-md-color-scheme="default"] {
--md-primary-fg-color: #1e1e2e;
--md-accent-fg-color: #74c7ec;
}
/* Dark mode */
[data-md-color-scheme="slate"] {
--md-default-bg-color: #1e1e2e;
--md-primary-fg-color: #74c7ec;
--md-accent-fg-color: #74c7ec;
}
- Set the theme to use custom colors in
mkdocs.yml:
Test Your Changes¶
- Run the development server:
- Open
http://localhost:8000in your browser - Toggle between light and dark modes to see your colors
- Adjust the color codes as needed
Tip
Use a color picker tool or visit Catppuccin Palette to find your preferred colors.