Coffeekraken.io 0.0.1

textWidth

Get the text width in px of a passed string or the passed HTMLElement

Name Type Description Status Default
source { String , HTMLElement } The source to process required

Return { Number } The calculated width of the text

Example

    import textWidth from 'sugarcss/js/dom/textWidth'
// text of an HTMLElement
const width = textWidth(myCoolHTMLElement);

// text directly (no font-size management so it's less accurate...)
const width = textWidth('Hello World');

Author : Olivier Bossel olivier.bossel@gmail.com