Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

pass props to svg

<svg width="160" viewBox="0 0 160 120">
    <defs>
        <g id="test">
            <rect width="60" height="40"/>
        </g>
    </defs>
    
    <g transform="translate(0,20)">
        <use href="#test" fill="aqua" stroke="blue" />
        <text x="10" y="25">Name</text>
    </g>
    <g transform="translate(80,20)">
        <use href="#test" fill="orange" stroke="red" />
        <text x="10" y="25">{props.text}</text>
    </g>
    
    <text y="100">This space for rent</text>
</svg>
 Run code snippet
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pass #props #svg
ADD COMMENT
Topic
Name
3+6 =