[SVG JS] Adding text inside polygon

[SVG JS] Adding text inside polygon

  
Forge Component
(1)
Published on 25 Oct by Frederico Sousa
1 vote
Published on 25 Oct by Frederico Sousa

Hello all,

is it possible for adding text inside the polygon?

Hi,


By default you shouldn't add text to the polygon you should have a text or textPath or a Path (should not be your first try) to add text to your SVG.

https://developer.mozilla.org/en-US/docs/Web/SVG/Element/polygon


you should go at the end with something like this.

<svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 64 64">
  <polygon fill="#F3BC23" stroke="#F3BC23" stroke-width="1" points="30,4,4,60,60,60"/>
  <text x="32" y="50" text-anchor="middle" fill="white" font-size="30">X</text>
</svg>


I check this component and right now its not possible to add text Elements(via webblock). Maybe you should contribute and make that improvement or go to other component. 


Good Luck!



I'm sorry I had a very busy day.


If you check the svg.js API you can see that it allows you to draw text by using one of these methods  (Link) 

It's a matter of doing those methods. I'll try to include this asap but you can also do it and then I can add you to the component team.