How I Unified the Mobile Sidebar Top Color with the Main Header in MkDocs Material #8196
Replies: 1 comment
-
As per the documentation you can set custom colors to the CSS variables and all related elements will have a unified color. In case of the header and mobile drawer the following CSS variables are being used: :root > * {
--md-primary-fg-color: #1B2733;
--md-primary-fg-color--dark: #000;
} Instead of setting them globally with Instead of using Specificity also applies to dark/white mode, as the theme adds |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
💡 How I Fixed the Mobile Drawer Header or Navigation Header Color in MkDocs Material
When working with MkDocs Material to build documentation, I successfully customized the color of the top header bar using CSS.
However, I noticed that on mobile devices, when you open the sidebar (the hamburger menu with three lines), the top section of the mobile drawer still remained the default purple color — even though I wanted it to match my customized header color.
🛠️ Problem
.md-header, .md-tabs
..md-drawer__header
.🔍 Solution
After inspecting the HTML and CSS structure, I realized that the mobile drawer’s top title bar is controlled by the following class:
This class targets the title area of the sidebar on mobile devices, so to synchronize its color with the desktop header, you need to override it explicitly in your extra.css file.
Final Steps
1. In your extra.css (already connected in mkdocs.yml):
Beta Was this translation helpful? Give feedback.
All reactions