Measure Text
Measure your text width and height in JavaScript
Getting Start
Install gz-measure-text
npm install gz-measure-text
Import measure text js:
; const text = "This is a long text";
Measure
For default setting:
const width height = ;
With custom style:
const style = ` font-size: 12px; font-family: Roboto, system-ui,PingFang SC,STHeiti,sans-serif; line-height: 20px;`; const width height = ;
For custom class name:
const width height = ;
For custom element tag name (default span
):
const width height = ;console;
maxWidth
High performance way to get max width of a set of texts
; const text = "This is a long text" "todo something" "what" "hahahah"; const res = ;console;