Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Components

Free

Textarea for Solid

Space for a comment, a message, or a note that won't fit on a single line. For Solid with Ark UI, the field grows as people type and scrolls if you cap the height.

Framework
UI library

Multi-line text for a comment, a bio, or a support note. It starts at a few lines.

Use it when the answer needs more than one line. A name, an email, or a search that must stay one line is an Input. In Solid, Ark UI renders a native textarea, so the value submits with the form.

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.
Use email insteadNo credit card

Anatomy

Textarea anatomy: textarea, caret, placeholder, resize handle

Usage

import { Textarea } from "@/components/ui/textarea";
const TextareaDemo = () => (
  <Textarea class="max-w-xs" placeholder="Type your message here." />
);

Demos

Field

A placeholder disappears the moment someone types, so it cannot be the name of the field. Put the textarea in a Field with a label of Message and a description between the label and the box, where it stays visible and gets announced. Anything a person fills in more than once should look like this, not like a bare box.

Preview width

Disabled

Set disabled on both the textarea and the Field around it, so typing stops, the cursor changes, and the label picks up the disabled styling too. Use it when the message depends on an earlier choice, or the viewer is not allowed to edit. A dim border that still accepts focus feels broken, because the prop is what actually blocks input.

Preview width

Invalid

After a bad submit, set invalid on the Field and aria-invalid on the textarea so the border and focus ring go destructive. The line underneath is the reason, and it should be the real one from your check, not a generic failure. FieldError is the better slot when that sentence should exist only while the field is invalid, while a description stays on screen the whole time.

Preview width

Button

A note with Send under it is the smallest message form: the textarea is the only field, and the button sits outside the box. Use the stack when sending that text is the whole action. When the button should live in the corner of the field, an input group is the composition, not a gap under the box.

Preview width

Rtl

Comments in Arabic, with dir set to rtl on the field, so the label, the caret, and the helper share a start edge. rows is 4 so there is room for a sentence rather than the short default. Set direction here or on the document, and skip physical padding that pins the text to the left.

Preview width

FAQ

How do I make a Textarea grow with its content in Solid?

It already does in browsers that support field-sizing: the Textarea has the field-sizing-content class, so it grows with its text from a minimum height of min-h-16. Set autoresize for browsers without field-sizing; it resizes with script.

How do I set a maximum height on a Textarea?

Add a max height class, for example max-h-40: the Textarea grows up to it and then scrolls. Add resize-none too if people should not drag the corner to resize it.

How do I add a label and help text to a Textarea?

Put it in a Field with a FieldLabel above it and a FieldDescription under it, as the Field demo does, so screen readers read the label with the Textarea. The Field links the label and description to it for you.

How do I show a validation error on a Textarea?

Set aria-invalid on it, or mark its Field invalid, as the Invalid demo does: the border and focus ring turn destructive. Show the message with a FieldError under it so it is announced.

How do I limit and count characters in a Textarea?

Set maxLength to stop typing past the limit. Keep the value in state and show its length next to the limit, for example "120 / 280", in the FieldDescription.

Does the Textarea work with form libraries in Solid?

Yes: it renders a native textarea, so it submits with a name and any form library can bind it. Bind its value like any textarea, and pass the form library's error state to its Field.

How do I install the Textarea in Solid?

Run the command in the Installation section above: it adds the Textarea to your ui folder. The command uses the shadcn CLI.

API Reference

Textarea

<textarea> data-slot="textarea"

PropType
autoresize?boolean

Whether the textarea should autoresize.

Default
false
asChild?(props: ParentProps) => JSX.Element

Render your own element: a function that gets the part's props to spread on it.

Type
(props: ParentProps) => JSX.Element
class?string

Merged with the part's classes.

With other components

  • Field

    Inputs

    Label, hint, and error

  • Label

    Inputs

    Name the box

  • Button

    Buttons

    Send under the box

  • Actions on the field

  • Card

    Layout

    Comment in a card

  • Badge

    Feedback

    The character count