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

CSS colors for Fontawesome icons do not work. #2103

Open
AAriam opened this issue Jan 22, 2025 · 1 comment · May be fixed by #2104
Open

CSS colors for Fontawesome icons do not work. #2103

AAriam opened this issue Jan 22, 2025 · 1 comment · May be fixed by #2104

Comments

@AAriam
Copy link
Contributor

AAriam commented Jan 22, 2025

The documentation says I can color Fontawesome icons like so:

i.fa-twitter-square:before {
   color: #55acee;
}

First, it's fa-square-twitter and not fa-twitter-square. Regardless, it does not work. For example, with the following conf.py (clean project with sphinx-quickstart):

html_static_path = ['_static']
html_css_files = ["styles.css"]
html_theme_options = {
   "icon_links": [
           {
               "name": "Twitter",
               "url": "https://twitter.com",
               "icon": "fa-brands fa-square-twitter",
           },
       ],
}

and _static/styles.css:

i.fa-square-twitter:before {
   color: #55acee;
}

the icon is still in the default grey color.
The only way I could get it to work was by targeting the class directly:

.fa-square-twitter {
   color: #55acee;
}

but since I wanted to add the color on hover, I had to do this:

a:hover .fa-square-twitter {
    color: #55acee
}

I'm using v0.16.1 with Sphinx 8.1.3.

@drammock
Copy link
Collaborator

You're correct that the example still uses the old name for that icon, it should be fa-square-twitter. You're also right that the example still doesn't work even if you fix that. That's because we switched to embedding the icons as svg nodes instead of i nodes (which also makes the ::before part incorrect). The guidance should be:

svg.fa-square-twitter {
    color: #55acee;
}

I'll open a quick PR. Thanks for flagging the mistake.

@drammock drammock linked a pull request Jan 22, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants