npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ngx-autosize-input

v20.0.5

Published

An Angular directive that automatically adjusts the width of an input element to its content. Unlike other auto-grow directives, it is unique because it both shrinks and increases the width based on the content.

Downloads

19,324

Readme

ngx-autosize-input

An Angular directive that automatically adjusts the width of an input element to its content. Unlike other auto-grow directives, it is unique because it both shrinks and increases the width based on the content.

npm npm License GitHub stars npm Downloads Status Checks codecov

Versions

The major version will match the Angular major version going forward (Angular 10+). For example version 10, will work for Angular 10.

Stack Blitz Demo

https://stackblitz.com/edit/angular-ivy-dtjmsk?file=src/app/hello.component.ts

Installation

npm install ngx-autosize-input

Add AutoSizeInputDirective to your @NgModule imports:

import {AutoSizeInputDirective} from "ngx-autosize-input";

@NgModule({
  imports: [
    AutoSizeInputDirective
  ]
})

The input options can be set from a provider (see below), or from the template (skip to the next section).

import {AUTO_SIZE_INPUT_OPTIONS, AutoSizeInputDirective, AutoSizeInputOptions} from 'ngx-autosize-input';

const CUSTOM_AUTO_SIZE_INPUT_OPTIONS: AutoSizeInputOptions = {
  extraWidth: 0,
  includeBorders: false,
  includePadding: true,
  includePlaceholder: true,
  maxWidth: -1,
  minWidth: -1,
  setParentWidth: false,
  usePlaceHolderWhenEmpty: false,
}

@NgModule({
  imports: [
    AutoSizeInputDirective
  ],
  providers: [
    { provide: AUTO_SIZE_INPUT_OPTIONS, useValue: CUSTOM_AUTO_SIZE_INPUT_OPTIONS }
  ]
})

Use Example

Use directly in your HTML templates on an input element:

<input autoSizeInput>

Using Bootstrap

If using Bootstrap, set the directive to include borders so that the text is not cut off.

<input autoSizeInput [includeBorders]=true>

Parameters

The following parameters customize the directive.

[extraWidth]

Add extra width, in units of pixels.

Default Value: 0px

Example (add 10px):

<input autoSizeInput [extraWidth]="10">

[includePlaceholder]

Set placeholder text width as minimum width; Note that [minimumWidth] will override this property.

Default Value: true

Example (turn off placeholder):

<input autoSizeInput [includePlaceholder]="false">

[includeBorders]

Includes border width, so that text is not cut off. Note only even left and right borders are supported at this time.

Default Value: false

Example (turn on include borders):

<input autoSizeInput [includeBorders]="true">

[includePadding]

Includes padding width, so that text is not cut off.

Default Value: true

Example (turn off include padding):

<input autoSizeInput [includePadding]="false">

[minWidth]

Sets minimum width, in units of pixels.

Default Value: 0

Example (50px minimum width):

<input autoSizeInput [minWidth]="50">

[maxWidth]

Sets maximum width, in units of pixels.

Default Value: 0

Example (100px maximum width):

<input autoSizeInput [maxWidth]="100">

[setParentWidth]

Sets parent width automatically, instead of input width. Useful when you need to update a parent's width.

Default Value: false

Example (input wrapped in an Angular Material form field component):

<mat-form-field> // This will be resized
   <input autoSizeInput [setParentWidth]="true">
</mat-form-field>

[usePlaceholderWhenEmpty]

Sets width to placeholder width, only when value is empty.

Default Value: false

Example (turn on placeholder when empty):

<input autoSizeInput [usePlaceholderWhenEmpty]="true">

[useValueProperty]

If the value of the form control is an object but the input value is formatted setting this value to true will use the value property of the input instead of retreiving the value from the form control or model. This option is not globally configurable and must be set on each input.

Default Value: false

Example (ngbTypeahead with inputFormatter): search$ returns an array of objects { firstName: string; lastName: string; }[] and formatInput transforms the selected object to `${firstName} ${lastName}`. The value applied to the form control will be the object selected so in-order to get the actual string value in the input we need to look at the value property.

<input autoSizeInput [useValueProperty]="true" formControlName="fullName" [ngbTypeahead]="search$" [inputFormatter]="formatInput">

Author

Joshua Wright

License

This project is licensed under the MIT license. See the License file for more info.