Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
react-expanding-textarea
Advanced tools
React textarea component to automatically expand and contract your textareas
React textarea component to automatically expand and contract your textareas.
You can view the demo here.
npm i react-expanding-textarea
Use this exactly like you would a normal <textarea>
; the only
difference is that it is doing some simple expanding work behind the scenes for
you!
import React, { useCallback, useEffect, useRef } from 'react'
import Textarea from 'react-expanding-textarea'
const MyTextarea = () => {
const textareaRef = useRef(null)
const handleChange = useCallback(e => {
console.log('Changed value to: ', e.target.value)
}, [])
useEffect(() => {
textareaRef.current.focus()
}, [])
return (
<>
<label htmlFor="my-textarea">
Please Enter Some Details:
</label>
<Textarea
className="textarea"
defaultValue="Lorem ipsum dolor sit amet, ..."
id="my-textarea"
maxLength="3000"
name="pet[notes]"
onChange={handleChange}
placeholder="Enter additional notes..."
ref={textareaRef}
/>
</>
)
}
rows
PropIf you pass a rows
prop, then this component will perform a calculation based
on computed lineHeight
, borderTopWidth
, borderBottomWidth
, paddingTop
and paddingBottom
to deduce what the minimum height-in-rows the component
should be.
resize
If for some reason you need to manually resize a <textarea>
, this package
exports a resize
function that has the following type:
interface Resize {
(rows: number, el: HTMLTextAreaElement | null): void
}
And you can use it like this:
import { resize } from 'react-expanding-textarea'
// resize based on 3 minimum rows
// and using a React ref
resize(3, refTextarea.current)
// or
// resize based on no minimum rows
// and using a regular DOM Node
resize(0, document.querySelector('textarea'))
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
FAQs
React textarea component to automatically expand and contract your textareas
The npm package react-expanding-textarea receives a total of 8,354 weekly downloads. As such, react-expanding-textarea popularity was classified as popular.
We found that react-expanding-textarea demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.