Skip to content
portalbits
Home Docs GitHub(opens in a new tab)

Guides

Get startedFoundationsMotion

Components

All components

Buttons

ButtonIconButton

Inputs

InputSelectTextareaSlider

Selection

CheckboxToggleToggleGroupSwitchRadioGroup

Identity

AvatarBadge

Overlays

DialogPopoverTooltipDropdownMenuAlertDialog

Disclosure

TabsAccordion

Cards

AppCardArticleCardFeatureCard

Content

CarouselSectionHeaderEmptyStateAlertProgressSeparatorRowListRow

Chrome

PortalShellSidebarNavMobileNavTopBarAuthFrameColorSelectorFloatingNav

Textarea

A labeled multiline field that grows with its rows.

31 of 200 characters

Variations

Source

<script lang="ts">
  import 'portal-bits/styles.css';
  import 'portal-bits/tokens.css';
  import type { Snippet } from 'svelte';

  let { children }: { children: Snippet } = $props();
</script>

{@render children()}
<script lang="ts">
  import TextareaExample from './TextareaExample.svelte';
</script>

<TextareaExample invalid={false} disabled={false} required={false} />
<script lang="ts">
  import { Alert, Textarea } from 'portal-bits';
  let {
    invalid = false,
    disabled = false,
    required = false,
  }: { invalid?: boolean; disabled?: boolean; required?: boolean } = $props();
  let note = $state('Pick up the prints on Thursday.');
</script>

<div class="field">
  <Textarea
    label="Project note"
    placeholder="What should the team know?"
    bind:value={note}
    {invalid}
    {disabled}
    {required}
    maxlength={200}
    aria-describedby={invalid ? 'note-error' : 'note-count'}
  />
  {#if invalid}
    <Alert id="note-error" message="Keep the note under 200 characters." />
  {:else}
    <p id="note-count">{note.length} of 200 characters</p>
  {/if}
</div>

<style>
  .field {
    width: 360px;
    max-width: 100%;
  }
  p {
    margin: 8px 0 0;
    color: var(--portal-muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
  }
</style>

API reference

These tables list the props and snippets that Textarea declares. Attributes passed through to an element or primitive are listed under Forwarded attributes, not here.

Props

NameTypeDefaultRequiredBindingDescription
labelstringNoneYesOne-wayThe visible label, tied to the field with `for`.
hideLabelbooleanfalseNoOne-wayKeeps the label for assistive technology only.
invalidbooleanfalseNoOne-waySets `aria-invalid`. Render the error text yourself.
valuestring""NoBindableThe field value.
rowsnumber4NoOne-wayVisible text lines before the field scrolls.
idstringGenerated idNoOne-wayThe textarea id. A stable id is generated when you omit it.
classstring""NoOne-wayExtra classes, added after the component classes.

Forwarded attributes

  • Native textarea attributes except `value`: `name`, `placeholder`, `maxlength`, `disabled`, `required`, `aria-*`, and handlers. They land on the `textarea` element.

No data attributes are documented as stable.

Limits

  • The 16px corner and 96px minimum height are an adaptation. Single-line fields keep the measured 32px pill.
  • The field resizes vertically only. It does not grow with its content.

Related

  • Input
  • Select
Previous Select Next Slider

On this page

  • Preview
  • Source
  • API reference
  • Props
  • Forwarded attributes
  • Limits