An open API service indexing awesome lists of open source software.

https://github.com/karesztrk/astro-svg-icon

A modern way to add icons to your Astro website.
https://github.com/karesztrk/astro-svg-icon

astro-component svg usetheplatform withastro

Last synced: 5 months ago
JSON representation

A modern way to add icons to your Astro website.

Awesome Lists containing this project

README

          

# Astro SVG Icon

This is a component that lets you add SVG icons to your Astro project using modern Web Standards. #UseThePlatform
The component utilizes the SVG `` tag, allowing the developer to include any external SVG asset, typically an icon for websites.

## How to use

```jsx
---
import Icon from 'astro-svg-icon';
import { Calendar } from 'Calendar.svg';
---

```

## Advantages

- 🚀 The image is loaded by the browser as an image, making caching possible
- 💅 An inline SVG tag allows for flexible styling with CSS.

## Limitations

- The `id` of the SVG must be the same as the name of the file. For example:

```html title="Calendar.svg"

```

Otherwise use the `reference` prop to specify the `id` of the sprite.

## References

Read on to find out why it's useful.

- https://kurtextrem.de/posts/svg-in-js
- https://karolytorok.netlify.app/blog/styling-an-svg/