You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

update-input-width

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

update-input-width

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

1.2.0
Source
npmnpm
Version published
Weekly downloads
279K
-4.12%
Maintainers
1
Weekly downloads
 
Created
Source

npm downloads build dependencies dev dependencies tested with jest

Update-Input-Width

A function that given 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'.
  • Pass input element to it. Forget.

User guide

updateInputWidth(element: HTMLInputElement)

A function that given 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
http://wojtekmaj.pl

Keywords

input width

FAQs

Package last updated on 29 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts