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

Set outline icons' stroke-width on <svg> for Tailwind compatibility #281

Closed

Conversation

andronocean
Copy link
Contributor

This PR makes Heroicons' outline icons compatible with Tailwind's stroke-width stroke-1, etc. classes, as well as any CSS styles applying the stroke-width property.

It fixes the problem discussed in #241, #236, and #263, by moving the stroke-width attribute from the <path> nodes to the <svg> element. This allows CSS inheritance to work properly when styles with higher specificity (like the Tailwind classes) are applied to the <svg>. (Link to the stroke-width spec for reference.)

Included are changes to all outline icons, plus the compiled optimized svgs. I've confirmed it works properly out-of-the-box and with the Tailwind classes.

I've built the react and vue versions from this too, and they look right to me, but since I don't use those it would be good to have someone double-check them closely before merging this.

@arpitjacob
Copy link

When can we get this merged, looking to incorporate this in a project I am working on.

@andronocean andronocean changed the title Stroke width on svg Set outline icons' stroke-width on <svg> for Tailwind compatibility Jun 3, 2021
@LoganDark
Copy link

Looks like heroicons is barely maintained, waiting for the fork

@LoganDark LoganDark mentioned this pull request Jul 31, 2021
LoganDark added a commit to LoganDark/heroicons that referenced this pull request Jul 31, 2021
@natemate90
Copy link

I added this to my global css:

@layer base {
  /* stroke-width: 2 is a browser default and can be overridden with class="stroke-1" etc. */
  svg {
    stroke-width: 2;
  }

  path,
  circle,
  ellipse,
  line,
  polygon,
  polyline,
  rect {
    stroke-width: inherit;
  }
}

@bradlc
Copy link
Contributor

bradlc commented Mar 1, 2022

Hey @andronocean. Really appreciate the work you've put into this! Rather than update the source SVG files we were able to update the SVGO configuration to automate this change and make it easier to maintain going forward. I hope you don't mind, but we've gone ahead and merged that PR instead, and credited you in the commit history 👍 Thanks again!

@bradlc bradlc closed this Mar 1, 2022
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 this pull request may close these issues.

None yet

5 participants