Use Textarea for form text fields. By default, the Textarea will grow to contain the text entered by the user.
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 for the textarea element.
<Textarea label="Message" /> Name of the textarea for form submission.
<Textarea name="message" label="Message" /> 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" /> 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" /> Default is true but can also be assigned a Boolean value like disabled={user.isSpammable}.
<Textarea label="Name" disabled /> Use fixed to disable the auto-expanding feature and show regular scrollbars as necessary.
<Textarea fixed /> Display error message below the field. Also adds error styles.
<Textarea error="Must be at least 40 million characters" /> A note prop let’s you define a note displayed below the field.
<Textarea note="This is a note" /> | Name | Type | Default | Description |
|---|---|---|---|
name | String | name of the textarea | |
placeholder | String | Textarea value description | |
label | String | Textarea | Text label appears above the textarea |
type | String | text | Textarea field types |
disabled | Boolean | false | Disables the textarea |
note | String | Text appears below textarea | |
error | String | Error message for the textarea | |
class | String | 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 |
| Name | Type | Default | Description |
|---|---|---|---|
--ui-textarea-font-size | Numeric | --ui-font-size, 1rem | Font size for value of field |
--ui-textarea-color | Color | --ui-dark, #1e293b | Text color for value of field |
--ui-textarea-border-width | Numeric | --ui-border-width, 1px | Border width |
--ui-textarea-border-color | Color | --ui-border-color, --ui-midtone, #94a3b8 | Border color |
--ui-textarea-border-radius | Numeric | --ui-border-radius, 3px | Border radius |
--ui-textarea-padding | Numeric | --ui-padding, 4px 6px | CSS padding shorthand |
--ui-textarea-outline-width | Numeric | --ui-outline-width, 1px | Outline width for :focus and .error |
--ui-textarea-outline-offset | Numeric | --ui-outline-offset, none | Outline offset for :focus and .error |
--ui-textarea-focus | Color | --ui-focus, #94a3b8 | Focus color applied to border and outline |
--ui-textarea-error | Color | --ui-textarea-error, --ui-error, #b91c1c | Error color for border, text, error note |