microsoft / fluentui-system-icons

Fluent System Icons are a collection of familiar, friendly and modern icons from Microsoft.
https://aka.ms/fluentui-system-icons
MIT License
5.93k stars 517 forks source link

Is there any way to generate a unique ID for clipPath in custom icons? #566

Open chenxinyanc opened 1 year ago

chenxinyanc commented 1 year ago

We are using wrapIcon function to create custom icons. We have used <clipPath id="..."> and other similar constructs in the <svg> element wrapped in our icon. Here is a (rather complex) example:

https://codesandbox.io/s/fluent-ui-v9-custom-icon-test-e7w1nz?file=/example.tsx

The point is, since we want to use url(#...) to reference a clipPath, we'll have to assign an ID to every clipPath. But ID is supposed to be globally unique in the whole HTML document, and there will definitely be such conflicts if we use such icon more than once.

Is there any suggestion on how we can generate a unique ID for our clipPath? Or are we creating custom icons in the wrong way?