unplugin-icons icon indicating copy to clipboard operation
unplugin-icons copied to clipboard

Ability to specify SVG title

Open sylvainpolletvillard opened this issue 2 years ago • 3 comments

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 avatar Feb 01 '22 13:02 sylvainpolletvillard

@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

userquin avatar Feb 02 '22 18:02 userquin

@sylvainpolletvillard working on adding i18n support new feature, stay turned... ;)

userquin avatar Mar 24 '22 16:03 userquin

I need to fix a few things, but it works, on mouse over the title will appear as a tootip:

imagen

imagen

userquin avatar Mar 24 '22 21:03 userquin