Textarea Autosize
A textarea component for React which grows with content.
- 📦 1.5 kB gzipped
The TextareaAutosize
component automatically adjust the textarea height on keyboard and window resize events.
<TextareaAutosize
aria-label="empty textarea"
placeholder="Empty"
style={{ width: 200 }}
/>
<TextareaAutosize
aria-label="minimum height"
minRows={3}
placeholder="Minimum 3 rows"
style={{ width: 200 }}
/>
<TextareaAutosize
maxRows={4}
aria-label="maximum height"
placeholder="Maximum 4 rows"
defaultValue="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua."
style={{ width: 200 }}
/>
Base
The TextareaAutosize component is defined in the @mui/base package. It is reexported from @mui/material for convenience. In your application you may import it from either package.
import TextareaAutosize from '@mui/base/TextareaAutosize';