Skip to content

Material Theme Not Applying Primary Color from mkdocs.yml #8176

Answered by mocdaniel
jwwojak asked this question in Q&A
Discussion options

You must be logged in to vote

This is expected behavior as per the docs on custom color palettes.

If you want to use custom colors not aliased by the builtin color variables (red, green, blue, indigo etc.), you'll need to do the following:

  1. Set the palette(s) colors to custom:

    theme:
      palette:
        primary: custom
        accent: custom
    
  2. Configure color variables in e.g. docs/stylesheets/extra.css:

    :root  > * {
      --md-primary-fg-color: #FF0000;
      --md-accent-fg-color:  #00BDFF;
    }
  3. Configure Material to use the additional CSS:

    extra_css:
      - stylesheets/extra.css

You can also define custom color palettes this way and reference them in your mkdocs.yaml, see the first link above.

Hope that helps!

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jwwojak
Comment options

jwwojak Apr 23, 2025
Author Sponsor

Answer selected by jwwojak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants