squidfunk / mkdocs-material

Documentation that simply works
https://squidfunk.github.io/mkdocs-material/
MIT License
20.11k stars 3.47k forks source link

Allow configuration of admonition, details, etc. icons via mkdocs.yml #2458

Closed Andre601 closed 3 years ago

Andre601 commented 3 years ago

I want to suggest an idea and checked that ...

Description

It would be a nice addition, if the Material theme could offer a setting for choosing your icon-set. I talk about the icons used in things such as admonition headers.

It could be an extra setting:

extra:
  icon-set: material # Uses Material icon set

extra:
  icon-set: fontawesome # Uses FontAwesome icon set

extra:
  icon-set: octicons # Uses Octicons icon set

Use Cases

It would allow people without a big CSS knowledge to switch to a different set of icons, if they don't like the default ones used. I'm well aware of the example on the reference section in the docs, about how to add custom icons. But in such a case like this one here would this create a rather large CSS file for just changing your icons used...

Screenshots / Mockups

image

squidfunk commented 3 years ago

This will be very tricky to pull off, but it's definitely a great idea! I'd rather not restrict it to an icon set (the default icons are all taken from Material), but to allow the user to specify an alternate icon for each admonition. We can then add some preset configurations to the docs for the FontAwesome and Octicon icons, fulfilling your feature request.

squidfunk commented 3 years ago

Note: this is yet unreleased

This turned out pretty great! Here's an example using custom icons from the Octicons icons package. Of course, this can be used with any icon from any package, even custom icons as described in the documentation.

mkdocs.yml

theme:
  icon:
    logo: logo
    admonition:
      note: octicons/tag-16
      abstract: octicons/checklist-16
      info: octicons/info-16
      tip: octicons/squirrel-16
      success: octicons/check-16
      question: octicons/question-16
      warning: octicons/alert-16
      failure: octicons/x-circle-16
      danger: octicons/zap-16
      bug: octicons/bug-16
      example: octicons/beaker-16
      quote: octicons/quote-16

Result:

localhost_8000_reference_admonitions_ (2)

Andre601 commented 3 years ago

That idea is actually even better than what I suggested. Good thinking there.

squidfunk commented 3 years ago

Insiders 2.4.0 just shipped support for custom admonition icons!

Andre601 commented 3 years ago

Insiders 2.4.0 just shipped support for custom admonition icons!

Cool. Will wait for the actual release...

Couldn't this be put on a lower insiders milestone? 👉👈 I can't afford to be part of insiders (yet) and the 8k milestone sure will take a long time to be reached...