Change the Heroicons SVG stroke width in React

I was using Heroicons in a Next.js app and they conveniently package the icons as React components.

One thing I wanted to do was customize the stroke width, so they rendered thinner.

I looked how to do that within the JSX, maybe with a prop,…


This content originally appeared on flaviocopes.com and was authored by flaviocopes.com

I was using Heroicons in a Next.js app and they conveniently package the icons as React components.

One thing I wanted to do was customize the stroke width, so they rendered thinner.

I looked how to do that within the JSX, maybe with a prop, but I couldn’t find a way.

I could import the SVG directly from the site, but I liked the React components approach.

For some reason I assumed setting a global CSS property directly didn’t work, as it was hardcoded in the SVG, but it actually worked:

svg path {
  stroke-width: 1;
}


This content originally appeared on flaviocopes.com and was authored by flaviocopes.com


Print Share Comment Cite Upload Translate Updates
APA

flaviocopes.com | Sciencx (2021-07-11T05:00:00+00:00) Change the Heroicons SVG stroke width in React. Retrieved from https://www.scien.cx/2021/07/11/change-the-heroicons-svg-stroke-width-in-react/

MLA
" » Change the Heroicons SVG stroke width in React." flaviocopes.com | Sciencx - Sunday July 11, 2021, https://www.scien.cx/2021/07/11/change-the-heroicons-svg-stroke-width-in-react/
HARVARD
flaviocopes.com | Sciencx Sunday July 11, 2021 » Change the Heroicons SVG stroke width in React., viewed ,<https://www.scien.cx/2021/07/11/change-the-heroicons-svg-stroke-width-in-react/>
VANCOUVER
flaviocopes.com | Sciencx - » Change the Heroicons SVG stroke width in React. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/07/11/change-the-heroicons-svg-stroke-width-in-react/
CHICAGO
" » Change the Heroicons SVG stroke width in React." flaviocopes.com | Sciencx - Accessed . https://www.scien.cx/2021/07/11/change-the-heroicons-svg-stroke-width-in-react/
IEEE
" » Change the Heroicons SVG stroke width in React." flaviocopes.com | Sciencx [Online]. Available: https://www.scien.cx/2021/07/11/change-the-heroicons-svg-stroke-width-in-react/. [Accessed: ]
rf:citation
» Change the Heroicons SVG stroke width in React | flaviocopes.com | Sciencx | https://www.scien.cx/2021/07/11/change-the-heroicons-svg-stroke-width-in-react/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.