The Icon
component is a lightweight, scalable solution for embedding vector graphics. It enables easy reference to SVG symbols for a consistent and customizable icon system.
Here's an example of the Icon
component in action:
<svg class="icon">
<use href="/assets/image/svg/icons.svg#icon-id"></use>
</svg>
The Icon
component is a simple SVG element that references symbols from the icons.svg
sprite sheet located at /assets/image/svg/
. To display an icon, reference its ID using the format icons.svg#icon-id
.
For example:
<use href="/assets/image/svg/icons.svg#star" />
Key points for using and customizing the Icon
component:
currentColor
, allowing it to inherit text color and adapt to theme changes.height: 1em;
and aspect-ratio: 1;
to maintain consistent size and proportions.aria-hidden="true"
for decorative icons or role="img"
with aria-label
for meaningful icons.