update-input-width

    1.2.2 • Public • Published

    npm downloads CI dependencies dev dependencies tested with jest

    Update-Input-Width

    A function that given an input element, updates its width to fit its content.

    tl;dr

    • Install by executing npm install update-input-width or yarn add update-input-width.
    • Import by adding import updateInputWidth from 'update-input-width'.
    • Use it by calling it with input element as an argument.

    User guide

    updateInputWidth(element: HTMLInputElement)

    A function that given an input element, updates its width to fit its content by setting inline width CSS property.

    Sample result

    42

    Usage

    import updateInputWidth from 'update-input-width';

    or

    import { updateInputWidth } from 'update-input-width';

    getFontShorthand(element: HTMLElement)

    A function that given HTML element returns font CSS shorthand property. Equal to Chrome-only code:

    window.getComputedStyle(element).font

    Sample result

    "normal normal 600 normal 20px / 25px Arial, sans-serif"

    Usage

    import { getFontShorthand } from 'update-input-width';

    measureText(text: string, font: string)

    A function that given text and font CSS shorthand property returns text width in pixels.

    Sample result

    42

    Usage

    import { measureText } from 'update-input-width';

    License

    The MIT License.

    Author

    Wojciech Maj
    kontakt@wojtekmaj.pl
    https://wojtekmaj.pl

    Keywords

    Install

    npm i update-input-width

    DownloadsWeekly Downloads

    112,034

    Version

    1.2.2

    License

    MIT

    Unpacked Size

    14.9 kB

    Total Files

    7

    Last publish

    Collaborators

    • wojtekmaj