dssoca docs
GitHub repository

Textarea

Multiline twin of Input with an autosize option.

A multiline text field that mirrors `Input`’s anatomy — label with auto-wired id, `hint`/`error` helper text (error implies aria-invalid and is announced), readonly/disabled styling, and native attribute forwarding — so the two sit side by side in a form without visual drift. Adds `rows` for the minimum height and an `autosize` mode that grows with content (`field-sizing: content` where supported, a scrollHeight fallback elsewhere) capped by `maxRows`.

Demo

live · storybook Open in Storybook

Demo loads from https://dssoca-storybook.vercel.app/. Run pnpm storybook for it to render locally.

Usage

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

<Textarea
  label="message"
  bind:value={message}
  placeholder="Say something nice…"
  hint="Markdown is fine."
  autosize
  maxRows={8}
/>

Shares `Input`’s field tokens (`--ss-input-*`) and focus/error treatment. The label is auto-associated even without an explicit `id`; `aria-describedby` orders error, then hint, then any caller-supplied ids, and the error is announced via `role="alert"`. Without `autosize` the field is manually resizable (vertical only); with it, resizing is handled by the content.

Props

PropTypeDefaultDescription
labelstringVisible label (associated via generated id).
valuestring''Bindable value.
placeholderstringPlaceholder text.
rowsnumber3Visible rows; the minimum height (also while autosizing).
autosizebooleanfalseGrow with content (`field-sizing: content`, JS fallback); disables manual resize.
maxRowsnumber10Row cap while autosizing — the field scrolls beyond it.
requiredbooleanfalseMarks the field required (adds a marker).
disabledbooleanfalseDisable the field.
readonlybooleanfalseNative readonly — value visible but not editable; rendered muted.
invalidbooleanApply invalid styling + aria-invalid (also implied by `error`).
hintstringHelper text rendered under the textarea and wired via aria-describedby.
errorstringError text under the textarea; implies aria-invalid and is announced to AT.
describedbystringid(s) of additional describing element(s) (aria-describedby).
maxlengthnumberNative maxlength.
oninput(e) => voidInput handler.
size'sm' | 'md' | 'lg'Per-instance size override; inherits the ancestor `data-size-variant` when unset.
...restHTMLTextareaAttributesAny remaining native textarea attributes / handlers are forwarded.