Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

203
Views
How to output the fontsize in .jsx

I have a .jsx file. The code is below.

What I want: I want to display a multiline text in the group : #someGroup.

My approach: I have inserted an empty <rect> as orientation where the text should be. So I know where to place the text in my svg.

<tspan> only starts at a defined coordinate. As far as I know there is no function that breaks the text after a certain number of characters.

My problem: Now I want to write a function myself which breaks the text after a certain length and inserts a new line in the form of <tspan> (as far as I know it only works with this), only a little further down.

I just can't figure out how to access the size of the respective font size.

With this, I would see how much % of the respective text fit into the first lines and then, if necessary, start a new line at a space.

With friendly greetings

How I return it:

<svg>
    ...
    <g id="someGroup">
    <rect id="someRect" x="296" y="51.3676"
    width="184" height="135.265" fill={"none"}/>
    <text id="testText" className={styles.testText}>
    {renderText}
    </text>
    </g>
    ... 
</svg>

/* The CSS: */

.testText{
    font-family: "Times New Roman", Times, serif;
    font-size: 17px;
    fill: black;
    letter-spacing: 0em;
}

My function (WIP)

function renderText(x,y fontsize ) {
    let message = `Please try another search term.`;
    return (
            <tspan x={"296"} y={"60"}>{message}</tspan>
    );
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!