Answers for "check string length pixel "react""

0

check string length pixel "react"

function getTextWidth(text, font) {
  const canvas = document.createElement('canvas');
  const context = canvas.getContext('2d');

  context.font = font || getComputedStyle(document.body).font;

  return context.measureText(text).width;
}
Posted by: Guest on April-15-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language