Skip to content

Inputs

TextArea

Multi-line text input with label, helper text, error state and configurable resize behavior.

<script>
  import { TextArea } from "@codeatlasdev/ui";
  let message = $state("");
</script>

<TextArea label="Message" bind:value={message} rows={4} />

The label sits above the field. description is hidden while an error is shown, and the error is announced with role="alert". Text stays at 16px or more on touch devices so iOS Safari does not zoom on focus. Native textarea attributes (maxlength, data-*, onkeydown, aria-label…) are spread on the <textarea>, bind:ref gives you the element, and hideLabel keeps the label for screen readers only.

#054

Basic

Empty, with a placeholder, and pre-filled.

Reference #054 · Pick in the gallery

Code
svelte
<script lang="ts">
  import { TextArea } from '@codeatlasdev/ui';

  let message = $state('');
  let notes = $state('');
  let description = $state('Some initial content here.');
</script>

<div class="col">
  <TextArea label="Message" bind:value={message} />
  <TextArea label="Notes" placeholder="Write something…" bind:value={notes} />
  <TextArea label="Description" bind:value={description} />
</div>

<style>
  .col {
    display: flex;
    flex-direction: column;
    gap: var(--ca-space-4);
    width: 100%;
    max-width: 480px;
  }
</style>
#055

States

Helper text, error, required, read-only, disabled and resize="none".

Max 500 characters.

Reference #055 · Pick in the gallery

Code
svelte
<script lang="ts">
  import { TextArea } from '@codeatlasdev/ui';

  let bio = $state('');
  let summary = $state('');
  let feedback = $state('');
  let fixed = $state('This textarea cannot resize.');
</script>

<div class="col">
  <TextArea label="Feedback" description="Max 500 characters." bind:value={feedback} />
  <TextArea
    label="Bio"
    bind:value={bio}
    error="Bio must be at least 20 characters."
    description="Tell us about yourself."
  />
  <TextArea label="Summary" required bind:value={summary} />
  <TextArea label="Read-only content" value="Cannot be edited." readonly />
  <TextArea label="Disabled content" value="Cannot be edited." disabled />
  <TextArea label="Fixed" bind:value={fixed} resize="none" rows={3} />
</div>

<style>
  .col {
    display: flex;
    flex-direction: column;
    gap: var(--ca-space-4);
    width: 100%;
    max-width: 480px;
  }
</style>

Props

PropTypeDefaultDescription
valuestring''Bindable text value.
labelstring–Label text.
hideLabelbooleanfalseRenders the label with `.ca-sr-only`: read by screen readers, not shown.
placeholderstring''Native placeholder.
rowsnumber4Visible row count.
minRowsnumber–Row count used for the minimum height. Defaults to rows.
resize'none' | 'vertical' | 'horizontal' | 'both''vertical'CSS resize behavior.
errorstring–Error message. Sets the error styling.
descriptionstring–Helper text shown below. Hidden when error is set.
helperTextstring–Deprecated alias of description. Use description.
disabledbooleanfalseDisables the textarea.
requiredbooleanfalseMarks the field as required, with a visual asterisk.
readonlybooleanfalseMakes the textarea read-only.
namestring–Native name, for form submission.
classstring–Extra classes on the root.
refHTMLTextAreaElement | null–Bindable native textarea element.
oninput(value: string) => void–Called on every keystroke with the new value.
onchange(value: string) => void–Called when the value is committed (on blur, after an edit).
onfocus(e: FocusEvent) => void–Called when the textarea gains focus.
onblur(e: FocusEvent) => void–Called when the textarea loses focus.