Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding FontAwesome icons for admonitions in base.css #3780

Open
daviewales opened this issue Jul 24, 2024 · 0 comments
Open

Consider adding FontAwesome icons for admonitions in base.css #3780

daviewales opened this issue Jul 24, 2024 · 0 comments
Labels
Theme-general Issues involving the theme related code within MkDocs Theme-mkdocs Issues specifically involving the mkdocs theme.

Comments

@daviewales
Copy link

daviewales commented Jul 24, 2024

Font Awesome is already included in MkDocs.
So it makes sense to use it to add icons to the default admonitions.

See the following CSS for example:

/* Fancy icons in admonitions... (Font Awesome 4.7.0) */

.admonition.note > .admonition-title::before {
  font-family: FontAwesome;
  /* fa-pencil */
  content: "\f040 ";
  margin-right: 0.5rem;
}

.admonition.info > .admonition-title::before {
  font-family: FontAwesome;
  /* fa-info-circle */
  content: "\f05a ";
  margin-right: 0.5rem;
}

.admonition.warning > .admonition-title::before {
  font-family: FontAwesome;
  /* fa-warning */
  content: "\f071 ";
  margin-right: 0.5rem;
}

.admonition.danger > .admonition-title::before {
  font-family: FontAwesome;
  /* fa-bomb */
  content: "\f1e2 ";
  margin-right: 0.5rem;
}

I'm on an older version of MkDocs, so the above is tested for Font Awesome 4.7 on MkDocs 1.5.2.
But the same concept with small tweaks should work for the latest version.

It may also make sense to include the Font Awesome icons in the HTML, rather than with the CSS hack above.

Example:

image

Note: I extracted the content: "\f1e2" values directly from font-awesome.css (v.4.7.0):
https://github.com/FortAwesome/Font-Awesome/blob/4.x/css/font-awesome.css

@pawamoy pawamoy added Theme-general Issues involving the theme related code within MkDocs Theme-mkdocs Issues specifically involving the mkdocs theme. labels Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Theme-general Issues involving the theme related code within MkDocs Theme-mkdocs Issues specifically involving the mkdocs theme.
Projects
None yet
Development

No branches or pull requests

2 participants