react-input-autosize

WebJar for react-input-autosize

License

License

MIT
Categories

Categories

React User Interface Web Frameworks Auto Application Layer Libs Code Generators
GroupId

GroupId

org.webjars.bower
ArtifactId

ArtifactId

react-input-autosize
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

react-input-autosize
WebJar for react-input-autosize
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/JedWatson/react-input-autosize

Download react-input-autosize

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bower/react-input-autosize/ -->
<dependency>
    <groupId>org.webjars.bower</groupId>
    <artifactId>react-input-autosize</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bower/react-input-autosize/
implementation 'org.webjars.bower:react-input-autosize:1.1.0'
// https://jarcasting.com/artifacts/org.webjars.bower/react-input-autosize/
implementation ("org.webjars.bower:react-input-autosize:1.1.0")
'org.webjars.bower:react-input-autosize:jar:1.1.0'
<dependency org="org.webjars.bower" name="react-input-autosize" rev="1.1.0">
  <artifact name="react-input-autosize" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bower', module='react-input-autosize', version='1.1.0')
)
libraryDependencies += "org.webjars.bower" % "react-input-autosize" % "1.1.0"
[org.webjars.bower/react-input-autosize "1.1.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

React-Input-Autosize

A text input for React that resizes itself to the current content.

Demo & Examples

Live demo: jedwatson.github.io/react-input-autosize

To run the examples locally, run:

npm install
npm start

Then open localhost:8000 in a browser.

Installation

The easiest way to use React-Input-Autosize is to install it from NPM and include it in your own React build process (using Browserify, rollup, webpack, etc).

You can also use the umd build by including dist/AutosizeInput.js in your page. If you use this, make sure you have already included a umd React build.

npm install react-input-autosize --save

Usage

React-Input-Autosize generates an input field, wrapped in a <div> tag so it can detect the size of its value. Otherwise it behaves very similarly to a standard React input.

import AutosizeInput from 'react-input-autosize';

<AutosizeInput
	name="form-field-name"
	value={inputValue}
	onChange={function(event) {
		// event.target.value contains the new value
	}}
/>

Gotchas

Changing the styles at runtime

The styles applied to the input are only copied when the component mounts. Because of this, subsequent changes to the stylesheet may cause size to be detected incorrectly.

To work around this, either re-mount the input (e.g. by providing a different key prop) or call the copyInputStyles() method after the styles change.

CSP and the IE "clear" indicator

The input will automatically inject a stylesheet that hides IE/Edge's "clear" indicator, which otherwise breaks the UI. This has the downside of being incompatible with some CSP policies.

To work around this, you can pass the injectStyles={false} prop, but if you do this I strongly recommend targeting the input element in your own stylesheet with the following rule:

input::-ms-clear {display: none;}

Custom font sizes

If your input uses custom font sizes, you will need to provide the custom size to AutosizeInput.

<AutosizeInput
	name="form-field-name"
	value={inputValue}
	inputStyle={{ fontSize: 36 }}
	onChange={function(event) {
		// event.target.value contains the new value
	}}
/>

Uncontrolled input

AutosizeInput is a controlled input and depends on the value prop to work as intended. It does not support being used as an uncontrolled input.

License

Copyright (c) 2018 Jed Watson. MIT License.

Versions

Version
1.1.0
0.6.13
0.6.2
0.6.1
0.5.3
0.4.5
0.4.4