unplugin-icons
unplugin-icons copied to clipboard
Ability to specify SVG title
Hello, and thanks for this great library.
I would like to add a title attribute to my icon components.
Problem is <svg title="Icon explaination"></svg>
does not provide a tooltip on mouseover as you would expect with any other HTML element. For SVG, the title must be a child element of the svg tag like this:
<svg xmlns="http://www.w3.org/2000/svg">
<title>icon explaination</title>
</svg>
which is out of reach at the moment with unplugin-icons
I wonder if it would be possible from unplugin-icons to support a title
prop for Icon components that would add this <title>
element as a child to SVG elements injected. Open to other suggestions as well. Thanks !
@sylvainpolletvillard you can add your custom compiler, check the vite-svelte
example: https://github.com/antfu/unplugin-icons/blob/main/examples/vite-svelte/vite.config.js and https://github.com/antfu/unplugin-icons/blob/main/examples/vite-svelte/src/CustomSvg.svelte
@sylvainpolletvillard working on adding i18n
support new feature, stay turned... ;)
I need to fix a few things, but it works, on mouse over the title will appear as a tootip: