Menu

Post image 1
Post image 2
1 / 2
0

The Icon Component I Keep Carrying

DEV Community·Tony Rowan·18 days ago
#AngnwL4e
#phase#rails#ruby#viewcomponent#size#options
Reading 0:00
15s threshold

Nearly every project I've worked on has, at some point, had to answer the question of inlining SVGs into HTML. I've been refining my approach to this from project to project and now have something stable and reusable I just drop into anything new. Why inline SVGs at all? Embedding SVG markup directly in your HTML gives CSS full access to the SVG's internals — fill: currentColor , stroke control, hover states, all of it. It also means your icons come along for free with the HTML you're already serving, rather than as a separate request per image. If you need a deeper primer on the approach, CSS Tricks has a good one . Phase 1: Reaching for a gem The first time this came up, I immediately reached for a gem. Everyone does, especially early in your career. The excellent inline_svg was the obvious choice.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More