# Adding a custom SVG to a plugin

**URL:** https://meta.discourse.org/t/adding-a-custom-svg-to-a-plugin/327148
**Category:** Development
**Created:** [September 18, 2024, 8:59pm UTC](https://meta.discourse.org/t/adding-a-custom-svg-to-a-plugin/327148 "2024-09-18T20:59:37Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Alteras](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alteras/32/179824_2.png) [@Alteras](https://meta.discourse.org/u/Alteras)
#### Post date: [September 18, 2024, 8:59pm UTC](https://meta.discourse.org/t/adding-a-custom-svg-to-a-plugin/327148/1 "2024-09-18T20:59:37Z")

</div>

I am looking to add a custom SVG icon to a plugin I am working on, but couldn’t find any documentation or topics on how to do so. All the documentation seems to be on doing it for a theme.

The `register_svg_icon` function seems to be only for FA icons, based on other plugin repos I’ve seen.

I imagine I can probably just put the SVG inside the public folder and pull it like a normal image, but I’d like to avoid it as a last resort.

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [September 18, 2024, 9:17pm UTC](https://meta.discourse.org/t/adding-a-custom-svg-to-a-plugin/327148/2 "2024-09-18T21:17:16Z")

</div>

`register_svg_icon` will work for any SVG, it isn’t specific to Font Awesome

So you’d add a new sprite with your icon, like `svg-icons/sprite.svg` — the guidance on the spritesheet is the same as [Replace Discourse's default SVG icons with custom icons in a theme](https://meta.discourse.org/t/replace-discourses-default-svg-icons-with-custom-icons-in-a-theme/115736) (so make sure to set an id)

Then in `plugin.rb` you can do:

`register_svg_icon "my-svg-id`"

---

<div class="post-metadata">

### Author: ![Alteras](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alteras/32/179824_2.png) [@Alteras](https://meta.discourse.org/u/Alteras)
#### Post date: [September 18, 2024, 11:10pm UTC](https://meta.discourse.org/t/adding-a-custom-svg-to-a-plugin/327148/3 "2024-09-18T23:10:30Z")

</div>

It works! Thank you!

I don’t suppose there’s a way to have the server watch for changes to the SVG file? Its a very minor inconvenience to refresh the page (and sometimes the dev server itself) every time I change the SVG.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [October 18, 2024, 11:10pm UTC](https://meta.discourse.org/t/adding-a-custom-svg-to-a-plugin/327148/4 "2024-10-18T23:10:40Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
