-
-
Notifications
You must be signed in to change notification settings - Fork 785
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
Create wiki page: how to change the fill color of an svg #6654
Comments
This comment was marked as outdated.
This comment was marked as outdated.
Hi @Maarimar, thank you for taking up this issue! Hfla appreciates you :) Do let fellow developers know about your:- You're awesome! P.S. - You may not take up another issue until this issue gets merged (or closed). Thanks again :) |
Availability: 05/09-05/11 |
Bellow is the draft of the new wiki page that explains how to customize the color of an SVG icon using CSS.How to Customize the Fill Color of an SVG IconWhile each icon type has a single SVG source file, you can control its displayed color using CSS. Here's how: Default Color Behavior:
Customizing Color Outside Project Resources:
Example Code Snippet:
By following these guidelines, you can effectively reuse SVG icons with dynamic color control while ensuring accessibility for all users. |
Hi @Maarimar this looks very nice, but I have a tiny issue with the example code that you selected. Was that sample code found in the HfLA website codebase? Please use this example instead:
When that is complete please move this issue into "Questions/In Review" and apply the label "ready for dev lead". Thank you! |
Please add update using the below template (even if you have a pull request). Afterwards, remove the 'To Update !' label and add the 'Status: Updated' label.
If you need help, be sure to either: 1) place your issue in the You are receiving this comment because your last comment was before Tuesday, May 21, 2024 at 12:06 AM PST. |
Hi! @roslynwythe it was an example from the code base. It was created here #6141. I have no problem changing it for the one you provided instead. |
@Maarimar thank you for creating this wiki page. I went ahead and added the link to How to Contribute to the Wiki and checked that box so this issue is complete! |
Overview
We require a wiki page to describe our strategy for reusing svg icons across the website by changing the fill color via CSS.
Details
_includes/svg/icon-slack.svg
so focus on the Slack icon for examplessass/elements/_icons.scss
specify that svg elements with class.icon
within the project resource section are displayed with their "native" color, but those outside the project resource section will have a defaultfill
color based on the current text color. The interior color of an svg is changed using the "fill" attribute.svg
element which allows the outer svg to specify attributes specific to the instance such as the svg-specific attributeviewBox
for scaling/positioning, aria attributes for accessibility, and class specifications for color. For an example see Replace slack-self-invite.svg with icon-slack.svg on CoP page #6141Action Items
Resources/Instructions
The text was updated successfully, but these errors were encountered: