Skip to content

← All components

Actions and forms

Textarea

Multi-line text entry with validation styling.

Live example

Usage

Each example includes the complete adapter-specific parameter reference. Copy it as a starting point, then remove options your use case does not need.

React

tsx
import { Textarea } from "@cofob/design-system-react";

/**
 * Complete Textarea parameter reference.
 * @param value/defaultValue
 *   type: string or string[]; controlled or initial value
 *   default: —
 *   example: "overview"
 * @param label
 *   type: string | renderable content
 *   default: —
 *   example: "Accessible label"
 * @param hint/description
 *   type: string | renderable content
 *   default: —
 *   example: "We will only use this for updates."
 * @param error
 *   type: string | renderable content
 *   default: —
 *   example: "Enter a valid value."
 * @param size
 *   type: "sm" | "md" | "lg" (plus heading sizes)
 *   default: "md"
 *   example: "md"
 * @param textarea attributes
 *   type: native element attributes
 *   default: —
 *   example: class / style / aria-* / data-*
 */
export function TextareaExample() {
  return (
    <Textarea label="Notes" />
  );
}

Svelte

svelte
<script lang="ts">
  import { Textarea } from "@cofob/design-system-svelte";

  // Complete Textarea parameter reference.
  // value/defaultValue
  //   type: string or string[]; controlled or initial value
  //   default: —
  //   example: "overview"
  // label
  //   type: string | renderable content
  //   default: —
  //   example: "Accessible label"
  // hint/description
  //   type: string | renderable content
  //   default: —
  //   example: "We will only use this for updates."
  // error
  //   type: string | renderable content
  //   default: —
  //   example: "Enter a valid value."
  // size
  //   type: "sm" | "md" | "lg" (plus heading sizes)
  //   default: "md"
  //   example: "md"
  // textarea attributes
  //   type: native element attributes
  //   default: —
  //   example: class / style / aria-* / data-*
</script>

<Textarea label="Notes" bind:value />

HTML

html
<!--
  Complete Textarea parameter reference.
  value/defaultValue
    type: string or string[]; controlled or initial value
    default: —
    example: "overview"
  label
    type: string | renderable content
    default: —
    example: "Accessible label"
  hint/description
    type: string | renderable content
    default: —
    example: "We will only use this for updates."
  error
    type: string | renderable content
    default: —
    example: "Enter a valid value."
  size
    type: "sm" | "md" | "lg" (plus heading sizes)
    default: "md"
    example: "md"
  textarea attributes
    type: native element attributes
    default: —
    example: class / style / aria-* / data-*
-->
<textarea class="cf-textarea"></textarea>

<script type="module">
  import { initDesignSystem } from "@cofob/design-system-css";

  const designSystem = initDesignSystem(document);
  window.addEventListener("pagehide", () => designSystem.destroy(), { once: true });
</script>

Parameters

Adapter differences are explicit. Native element attributes are forwarded in React and Svelte and can be written directly in HTML.

ParameterTypeDefaultAdaptersExampleDescription
value/defaultValuestring or string[]; controlled or initial valueReact · Svelte · HTML"overview"Use the first form for controlled state and the second for initial state.
labelstring | renderable contentReact · Svelte · HTML"Accessible label"Visible or accessible name, depending on the component.
hint/descriptionstring | renderable contentReact · Svelte · HTML"We will only use this for updates."Supporting text announced with the control.
errorstring | renderable contentReact · Svelte · HTML"Enter a valid value."Validation message and invalid visual/ARIA state.
size"sm" | "md" | "lg" (plus heading sizes)"md"React · Svelte · HTML"md"Applies a design-system size token.
textarea attributesnative element attributesReact · Svelte · HTMLclass / style / aria-* / data-*Forwards native class/style, accessibility, event, and data attributes to the root element.