当文本超过文本方面的高度尾风CSS(黛西UI)时,可以调整textarea的大小
IM试图使用尾风CSS在React应用程序中调整TextArea的大小,但是,当我启用调整大小时,当文本超过文本方面的高度时,我将无法再调整TextAarea的大小。
事情的屏幕截图
- 以下是文本超过高度之前
- 之前
发生的 a href =“ https://i.sstatic.net/ffqee.png” rel =“ nofollow noreferrer”>文本超过高度之后
下面是为textarea创建的组件
<div className='form-control w-full'>
<label className='label'>
<span className='label-text text-primary'>{title}</span>
</label>
<textarea
placeholder={placeholder}
className={`textarea w-full resize-y ${
value !== text ? 'bg-green-100' : 'bg-white'
}`}
value={text}
onChange={(e) => {
setText(e.target.value);
debounced(e.target.value);
}}
/>
</div>
此textarea组件包裹在以下代码中
<div className="flex flex-row flex-wrap">
{descriptions.map((field: CollapsibleInputField, i: number) => (
<div
key={i}
className={
field.placeholder === "English" ? "w-full pr-2" : "w-1/2 pr-2"
}
>
<TextAreaContainer
id={field.id}
value={field.data}
placeholder={field.placeholder}
title={field.title}
/>
</div>
))}
</div>
我在做什么错?
Im trying to enable resizing of TextArea in a react application using TailWind CSS, however when I do enable resizing, when the text exceeds the height of TextArea I'm unable to resize the TextArea anymore.
Below are screenshots of what is happening
- Before Text exceeds height
- After Text exceeds height
Below is the component created for the TextArea
<div className='form-control w-full'>
<label className='label'>
<span className='label-text text-primary'>{title}</span>
</label>
<textarea
placeholder={placeholder}
className={`textarea w-full resize-y ${
value !== text ? 'bg-green-100' : 'bg-white'
}`}
value={text}
onChange={(e) => {
setText(e.target.value);
debounced(e.target.value);
}}
/>
</div>
This TextArea component is wrapped in the following code
<div className="flex flex-row flex-wrap">
{descriptions.map((field: CollapsibleInputField, i: number) => (
<div
key={i}
className={
field.placeholder === "English" ? "w-full pr-2" : "w-1/2 pr-2"
}
>
<TextAreaContainer
id={field.id}
value={field.data}
placeholder={field.placeholder}
title={field.title}
/>
</div>
))}
</div>
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在尝试使用该调整大小来使文本动态根据文本进入其中。但是,您需要使用REF观察元素,并增加Textarea动态的高度。
这可以解决问题。
You are trying use the resize to let the textarea dynamic according to the text into there. But, you need observer the element using the ref for example and increase the height of textarea dynamic.
This could solve it the problem.