Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
react-input-autosize
Advanced tools
The react-input-autosize package is a React component that automatically adjusts the width of the input field to fit the content typed by the user. This is particularly useful for tags input and other dynamic text inputs where the size of the content can change.
Autosizing input field
This feature allows the input field to automatically resize based on the input content. The width of the input will grow or shrink as the user types or deletes content.
{"import AutosizeInput from 'react-input-autosize';\n\nfunction MyComponent() {\n const [value, setValue] = useState('');\n\n return (\n <AutosizeInput\n value={value}\n onChange={(e) => setValue(e.target.value)}\n />\n );\n}"}
This package provides a textarea element that automatically resizes as content changes. It's similar to react-input-autosize but is specifically designed for textarea elements instead of input fields.
Similar to react-autosize-textarea, this package is for textarea elements that automatically adjust their height to the content. It offers a similar functionality to react-input-autosize but for multi-line text areas.
This package is similar to react-input-autosize and provides an input field that adjusts its width to the content. It's a lightweight alternative that can be used outside of React as well.
A text input for React that resizes itself to the current content.
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.
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
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
}}
/>
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.
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;}
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
}}
/>
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.
Copyright (c) 2018 Jed Watson. MIT License.
v3.0.0 / 2020-12-11
This release adds support for React 17 and removes usage of UNSAFE React lifecycle methods, thanks to Nathan Bierema.
It should be a fairly painless major upgrade since the API hasn't been changed at all. It's being published as 3.0.0
because the peer dependency range has been updated and the internal implementation has changed.
FAQs
Auto-resizing Input Component for React
The npm package react-input-autosize receives a total of 1,234,332 weekly downloads. As such, react-input-autosize popularity was classified as popular.
We found that react-input-autosize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.