Alert Avatar AvatarGroup Button ButtonGroup Checkbox CheckboxGroup FilePicker Form FormRow Hamburger Input Modal Option Radio RadioGroup Rating Select Spinner Textarea Toast Tooltip Toggle

Textarea

Use Textarea for form text fields. By default, the Textarea will grow to contain the text entered by the user.


Example

Type in the field to see the value change.

<script>
  import { Textarea } from '$lib/ui'
  let message = $state('');
</script>

<Textarea bind:value={message} />

<p>Message: {message}</p>

Message:


Label

Label for the textarea element.

<Textarea label="Message" />

Name

Name of the textarea for form submission.

<Textarea name="message" label="Message" />

Height

Use height to set the initial height of the textarea. If using CSS utility classes (like Tailwind), you can also set the height with something like class="!h-48" (using the Tailwind ! important flag to override default style).

<Textarea height="10rem" />

Placeholder

A placeholder prop let’s you define a simple String to be used as a simple descriptor for the input value.

<Textarea placeholder="Jane Doe" />

Disabled

Default is true but can also be assigned a Boolean value like disabled={user.isSpammable}.

<Textarea label="Name" disabled />

Fixed

Use fixed to disable the auto-expanding feature and show regular scrollbars as necessary.

<Textarea fixed />

Error

Display error message below the field. Also adds error styles.

<Textarea error="Must be at least 40 million characters" />
Must be at least 40 million characters

Note

A note prop let’s you define a note displayed below the field.

<Textarea note="This is a note" />
This is a note

Textarea Component Props

Name Type Default Description
nameString name of the textarea
placeholderString Textarea value description
labelStringTextareaText label appears above the textarea
typeStringtextTextarea field types
disabledBooleanfalseDisables the textarea
noteString Text appears below textarea
errorString Error message for the textarea
classString CSS classes declared in global scope can be applied to the outermost element
...  Additional props will be passed through to the HTML element enabling support for things like on:click, etc

Textarea CSS Custom Properties

Name Type Default Description
--ui-textarea-font-sizeNumeric--ui-font-size, 1remFont size for value of field
--ui-textarea-colorColor--ui-dark, #1e293bText color for value of field
--ui-textarea-border-widthNumeric--ui-border-width, 1pxBorder width
--ui-textarea-border-colorColor--ui-border-color, --ui-midtone, #94a3b8Border color
--ui-textarea-border-radiusNumeric--ui-border-radius, 3pxBorder radius
--ui-textarea-paddingNumeric--ui-padding, 4px 6pxCSS padding shorthand
--ui-textarea-outline-widthNumeric--ui-outline-width, 1pxOutline width for :focus and .error
--ui-textarea-outline-offsetNumeric--ui-outline-offset, noneOutline offset for :focus and .error
--ui-textarea-focusColor--ui-focus, #94a3b8Focus color applied to border and outline
--ui-textarea-errorColor--ui-textarea-error, --ui-error, #b91c1cError color for border, text, error note