0.0.3 • Published 6 years ago
mat-input-autosize v0.0.3
MatInputAutosize

mat-input-autosize is an Angular directive that allows Material input elements to fit the width of their contents.
Details
This directive uses CSS styles to resize a matInput element dynamically. It removes the hard coded width from the matInput, and adds an invisible text element to set the width.
Usage
- Import the module with:
import { MatInputAutosizeModule } from 'mat-input-autosize'. - Add
MatInputAutosizeModuleto your NgModule's imports array. - Apply the directive
matInputAutosizeto your element that has amatInputdirective on it.
Configuration
The matInputAutosize directive has three optional inputs, which all take CSS styles:
matInputAutosizeMinWidth- Sets the minimum width the input will shrink to. (default: 120px)matInputAutosizeMaxWidth- Sets the maximum width the input will grow to.matInputAutosizeFontStyle- If the automatic width is incorrect, pass the computedfontstyle of the input box to fix it.
Config Example
<input matInput
matInputAutosize
matInputAutosizeMinWidth='80px'
matInputAutosizeMaxWidth='160px'
matInputAutosizeFontStyle='12px Roboto, sans-serif'>