tailwindlabs / heroicons

A set of free MIT-licensed high-quality SVG icons for UI development.
https://heroicons.com
MIT License
21.04k stars 1.26k forks source link

Allow setting title via prop #779

Closed stefanprobst closed 1 year ago

stefanprobst commented 1 year ago

This enables svgr's titleProp option which allows adding a <title> to jsx icons via prop.

RobinMalfait commented 1 year ago

Hey! Thank you for your PR! Much appreciated! 🙏

I don't think this is necessary because all props are already added to the SVG (e.g.: https://unpkg.com/browse/@heroicons/react@2.0.8/20/solid/AcademicCapIcon.js)

Here is an example in a CodeSandbox. If you look at the DOM you will see the title attribute: https://codesandbox.io/s/hardcore-pond-p51n6x?file=/src/App.js

stefanprobst commented 1 year ago

hi, the titleProp option adds a title element as a child of the svg (not a title attribute on the svg) - i think for svgs this is the appropriate approach (?)

stefanprobst commented 1 year ago

actually, hovering over the svg in your codesandbox does not show a title tooltip for me

RobinMalfait commented 1 year ago

Aha yeah ok that makes sense. Thanks for the PR!