natemoo-re / astro-icon

Inline and sprite-based SVGs in Astro made easy!
https://astroicon.dev
Other
1.01k stars 57 forks source link

Use in non-astro components? #41

Closed silveltman closed 1 year ago

silveltman commented 2 years ago

Can this be used in components other than .astro? Like .svelte, .vue etc.

I'm getting an error but not sure what the exact reason for this is

yacosta738 commented 1 year ago

Hi, I am interested in use in other components. Is that possible?

kissu commented 1 year ago

I guess that we could use https://github.com/antfu/unplugin-icons for the other languages but it's indeed a bit counter-productive to have both to cover every extension.

stramel commented 1 year ago

You can use the Icon component in other framework components by utilizing the <slot /> feature.

https://docs.astro.build/en/core-concepts/framework-components/#can-i-use-astro-components-inside-my-framework-components

kissu commented 1 year ago

I will need to give that one a try!

stramel commented 1 year ago

@kissu here is an example using with React. https://stackblitz.com/edit/github-6zni2a?file=src/components/Card.jsx https://stackblitz.com/edit/github-6zni2a?file=src/pages/index.astro

stramel commented 1 year ago

Going to close this since this is possible. Feel free to comment if you're experiencing issues.

wpplumber commented 1 year ago

Welcome, is there a Vue 3 sample?

Corentin7301 commented 11 months ago

@wpplumber Do you have find an example with Vue 3? I've the following problem:

| index.astro
| components
  | Slider.vue
  | Card.vue

I use a v-for in Slider and send data of card by props to Card. In this card, I would like to add icons but I don't find a solution for that...

wpplumber commented 11 months ago

Welcome @Corentin7301, I use unplugin now. 💪