forms
Tailwind CSS Textarea
A textarea is a multi-line text input field that allows users to enter longer text.
Basic textarea example.
Basic textarea with placeholder.
The textarea-floating
style is used to define the appearance of the textarea, while the textarea-floating-label
is the container for the label text. To handle cases where the content exceeds the initial size, we applied the field-sizing: content;
CSS rule, allowing the textarea to expand when the content exceeds the set maximum height of 5rem
(m-h-20
).
The textarea-filled
style is applied to the textarea, with textarea-filled-label
for the label and textarea-filled-focused
for focus animations. The textarea auto-expands beyond a 5rem
max height using field-sizing: content;
.
Success state can be show using is-valid
class.
Error state can be show using is-invalid
class.
label
elements hidden using the .sr-only class.
Add the disabled
boolean attribute on an textarea to remove pointer events, and prevent focusing.
Add the readonly
boolean attribute on an textarea to prevent modification of the textarea value.
Basic textarea example with helper text and hints.