TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: SVG-to-React – convert your SVG assets into accessible React components

4 pointsby TheSisb2over 5 years ago

1 comment

TheSisb2over 5 years ago
Hey HN! I&#x27;m really happy to be sharing this with you all today. I&#x27;ve been working on React projects for about 4 years now and I&#x27;ve always found that SVGs (whether icons or full illustrations) are best represented in my projects as individual React components. Some of the benefits are that:<p>- It&#x27;s easier to control your SVGs with clearly defined props<p>- You can bake in accessibility into your illustrations<p>- Unlike to icon fonts which load the entire font, you can leverage modern module loading practices to only load the SVGs you need (i.e.: import HackerNewsIcon from &#x27;...&#x27;)<p>- Unlike in-lining SVGs, the resource can be cached, bundled, and re-used multiple times without duplicating the contents.<p>- This tool automatically strips away `id`s so you don&#x27;t have id collisions.<p>- Since it&#x27;s a component, you can modify it to, for example, show a different SVG under a different locale if the English design doesn&#x27;t translate well.<p>This has helped our little design system team off-load the incoming requests to add new icons back out to the requesting teams. And if an icon doesn&#x27;t meet the requirements of our system, consumers can continue to use them in their own projects while still being aligned on props and a11y.<p>Hope you all find this useful too!