Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<symbol> + <use>? #68

Open
mustafa0x opened this issue Dec 8, 2024 · 4 comments
Open

<symbol> + <use>? #68

mustafa0x opened this issue Dec 8, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@mustafa0x
Copy link

Awesome project, thanks! I have an svg file with content like

<svg style="display: none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg">
  <defs>
    <symbol id="foo" viewBox="0 0 20 20"><path d="..."/></symbol>
    <symbol id="bar" viewBox="0 0 20 20"><path d="..."/></symbol>
  </defs>
</svg>

Then I would embed a specific symbol using <svg class="icon"><use href="icons.svg#foo"></svg>

Using this plugin, is there an easy way to achieve this?

@poppa
Copy link
Owner

poppa commented Dec 10, 2024

Hi @mustafa0x!

I'm not sure what you'd like this plugin to achieve in this case?

@korywka
Copy link

korywka commented Dec 16, 2024

I think he is about using SVG sprites: https://css-tricks.com/svg-sprites-use-better-icon-fonts/
IMHO not a scope of this plugin.

@mustafa0x
Copy link
Author

mustafa0x commented Dec 16, 2024

Yes, sorry for not clarifying. I'm trying to figure out the easiest way to reference a <symbol> from an svg file, using this plugin.

Given this svg

<svg style="display: none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg">
  <defs>
    <symbol id="logo" viewBox="0 0 20 20"><path d="..."/></symbol>
  </defs>
</svg>

I'd like to get logo using something like this

<script>
import Icons from "./icons.svg?component"
</script>

<Icons id="logo" />

or this

<script>
import Logo from "./icons.svg?component&symbol=logo"
</script>

<Logo />

@poppa poppa added the enhancement New feature or request label Dec 21, 2024
@poppa
Copy link
Owner

poppa commented Dec 21, 2024

I will look in to this during the hollidays, to see if I can come up with a viable solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants