JSFiddle - React, Tailwind, and code Playground
by Chris Ball
HTML
<canvas id="myCanvas" width="300" height="150" style="border:1px solid grey"></canvas>
JavaScript
let c = document.getElementById("myCanvas");
let ctx = c.getContext("2d");
ctx.font = "30px Arial";
let txt = "Hello World"
let measurements = ctx.measureText(txt)
// console.log(measurements)
for (const m in measurements) {
console.log(m, measurements[m])
}