https://github.com/coreprocess/unstyled-textarea-autosize
An unstyled multi-line text component for React that adapts to its content.
https://github.com/coreprocess/unstyled-textarea-autosize
autosize component multi-line multiline react textarea unstyled
Last synced: 5 months ago
JSON representation
An unstyled multi-line text component for React that adapts to its content.
- Host: GitHub
- URL: https://github.com/coreprocess/unstyled-textarea-autosize
- Owner: coreprocess
- Created: 2023-01-27T08:15:42.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-19T13:48:56.000Z (almost 3 years ago)
- Last Synced: 2025-02-17T01:32:52.690Z (11 months ago)
- Topics: autosize, component, multi-line, multiline, react, textarea, unstyled
- Language: TypeScript
- Homepage:
- Size: 40 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# <UnstyledTextareaAutosize />


`` is an unstyled multi-line text component for React that adapts to its content.
## Installation
Use your favourite manager to install the [package](https://www.npmjs.com/package/unstyled-textarea-autosize):
```sh
yarn add unstyled-textarea-autosize
```
```sh
npm install unstyled-textarea-autosize --save
```
## Example
```ts
import React from "react";
import { UnstyledTextareaAutosize } from "unstyled-textarea-autosize";
export function Example({
value,
onChange,
}: {
value: string;
onChange: (value: string) => void;
}) {
return (
);
}
```
## Properties
The component accepts all properties of the intrinsic `div` component, including the `style` and `className` properties. In addition, it accepts the following properties:
- `readOnly?: boolean`: Content cannot be edited if set to `true`.
- `value?: string`: The current content value of the text component (controlled mode).
- `initialValue?: string`: The initial content value of the text component (uncontrolled mode).
- `onValueChange?: (value: string) => void`: A callback function that is called each time the user edits the content.
## Attributes
A reference to the component provides all attributes of the intrinsic `div` DOM element. In addition, it provides the following attribute:
- `value: string`: The current content value of the text component.
Please use the exported type `UnstyledTextareaAutosizeElement` for the reference.
## License
This library is licensed under the MIT license.
## Contributing
We welcome contributions to the `unstyled-textarea-autosize` library. To contribute, simply open a [pull request](https://github.com/teamrevin/unstyled-textarea-autosize/pulls) with your changes.