{
  "component": "Textarea",
  "package": "@blade-ai/weft",
  "import": "import { Textarea } from \"@blade-ai/weft/components/textarea\";",
  "status": "stable",
  "version": "0.1.0",
  "updated": "2026-11-24",
  "docs": "/components/textarea",
  "description": "A multi-line field with a visible label, help text, validation and an optional character counter. One size; rows sets the height, auto-grows by default.",
  "props": [
    {
      "name": "label",
      "type": "string",
      "default": null,
      "required": true,
      "description": "Visible label. Placeholder never replaces it."
    },
    {
      "name": "labelPosition",
      "type": "\"top\" | \"left\"",
      "values": [
        "top",
        "left"
      ],
      "default": "top",
      "required": false,
      "description": "left = 80px label column beside the textarea."
    },
    {
      "name": "labelWidth",
      "type": "number (px)",
      "default": 80,
      "required": false,
      "description": "Label column width when labelPosition=\"left\". No token."
    },
    {
      "name": "placeholder",
      "type": "string",
      "default": null,
      "required": false,
      "description": "An example value, never a label."
    },
    {
      "name": "value · defaultValue",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Controlled or uncontrolled value. Pair value with onChange."
    },
    {
      "name": "onChange",
      "type": "(value: string) => void",
      "default": null,
      "required": false,
      "description": "Fires with the new value."
    },
    {
      "name": "onBlur",
      "type": "(event: FocusEvent) => void",
      "default": null,
      "required": false,
      "description": "Validate here, not on every keystroke."
    },
    {
      "name": "rows",
      "type": "number",
      "default": 3,
      "required": false,
      "description": "Initial visible rows; fixed height when isAutoGrow is false. Rows 3 = 78px (rows x 20 + 16 + 2)."
    },
    {
      "name": "minRows · maxRows",
      "type": "number",
      "default": null,
      "required": false,
      "description": "Auto-grow bounds. Defaults: UNDEFINED. minRows falls back to rows; maxRows to unbounded."
    },
    {
      "name": "isAutoGrow",
      "type": "boolean",
      "default": true,
      "required": false,
      "description": "Grows with content (field-sizing: content), then scrolls past maxRows."
    },
    {
      "name": "resize",
      "type": "\"vertical\" | \"none\"",
      "values": [
        "vertical",
        "none"
      ],
      "default": null,
      "required": false,
      "description": "Always none while isAutoGrow. Default when fixed: UNDEFINED (renders none)."
    },
    {
      "name": "validationState",
      "type": "\"none\" | \"error\" | \"success\"",
      "values": [
        "none",
        "error",
        "success"
      ],
      "default": "none",
      "required": false,
      "description": "error sets aria-invalid=\"true\"."
    },
    {
      "name": "helpText",
      "type": "ReactNode",
      "default": null,
      "required": false,
      "description": "Guidance under the textarea."
    },
    {
      "name": "errorText",
      "type": "ReactNode",
      "default": null,
      "required": false,
      "description": "Shown instead of helpText when validationState=\"error\", prefixed \"! \"."
    },
    {
      "name": "successText",
      "type": "ReactNode",
      "default": null,
      "required": false,
      "description": "Shown instead of helpText when validationState=\"success\", prefixed \"✓ \"."
    },
    {
      "name": "isRequired",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Adds * to the label and aria-required."
    },
    {
      "name": "isDisabled",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Not focusable, not submitted, no resize; opacity 50% on the whole field."
    },
    {
      "name": "isReadOnly",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Focusable, submitted, selectable. Tokens: UNDEFINED; drawn with filled tokens, no caret."
    },
    {
      "name": "isLoading",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Spinner top-right inside the box, aria-busy. Editable while loading: UNDEFINED (stays editable)."
    },
    {
      "name": "maxLength",
      "type": "number",
      "default": null,
      "required": false,
      "description": "Not enforced natively: paste is never blocked, going over shows an error. Counting unit: UNDEFINED (counts UTF-16 length)."
    },
    {
      "name": "showCounter",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Shows \"count/maxLength\" right of the help text. Needs maxLength."
    },
    {
      "name": "onSubmitShortcut",
      "type": "() => void",
      "default": null,
      "required": false,
      "description": "Cmd / Ctrl + Enter handler. Prop name: UNDEFINED. Plain Enter always inserts a new line."
    }
  ],
  "undefined": [
    "Scrollbar tokens",
    "Read-only look (no tokens) and resize while read-only",
    "Focused + invalid border (error wins, as in Text Input)",
    "Editable while loading (stays editable)",
    "maxLength block vs allow + flag (allows + flags) and counting unit (UTF-16)",
    "Near-limit threshold (90% as drawn in Paper)",
    "minRows / maxRows defaults",
    "Default resize (none)",
    "onSubmitShortcut prop name",
    "Chat-style Enter-to-submit (not built)",
    "Success border and background"
  ],
  "sizes": {
    "height": "rows x 20 + 16 + 2px (rows 3 = 78px) · size.78",
    "padding": "12px x · 8px y · spacing.4 / spacing.3",
    "valueAndPlaceholder": "13/20 · typography.fonts.size.1200 / typography.lineHeights.100",
    "counter": "12/16 mono · typography.fonts.family.code",
    "spinner": "16px, top-right; text gets 32px right padding",
    "labelTextareaHelpGap": "top 8px (spacing.3) · left 12px (spacing.4)",
    "helpText": "12/16 · tracking 0.01em",
    "leftLabelColumn": "80px (no token)",
    "borderAndRing": "border.width.thin · ring border.width.3 + interactive.border.primary.faded",
    "radius": "border.radius.none (themeable via --weft-radius)",
    "disabledOpacity": "opacity.600",
    "maxHeight": "maxRows x 20 + 16 + 2px; UNDEFINED default"
  },
  "states": [
    {
      "name": "default (empty)",
      "trigger": "value = \"\", not focused",
      "tokens": {
        "bg": "surface.background.gray.subtle",
        "border": "interactive.border.gray.default",
        "placeholder": "surface.text.gray.muted",
        "help": "surface.text.gray.muted"
      }
    },
    {
      "name": "hover",
      "trigger": "pointer over the textarea, not focused / invalid / disabled / read-only",
      "tokens": {
        "border": "interactive.border.gray.highlighted"
      }
    },
    {
      "name": "focus-visible",
      "trigger": "textarea focused",
      "tokens": {
        "border": "interactive.border.primary.default",
        "ring": "border.width.3 interactive.border.primary.faded",
        "caret": "surface.text.gray.normal"
      }
    },
    {
      "name": "active / pressed",
      "trigger": "pointer down",
      "tokens": {
        "same": "focus-visible"
      }
    },
    {
      "name": "filled",
      "trigger": "value.length > 0",
      "tokens": {
        "text": "surface.text.gray.normal"
      }
    },
    {
      "name": "counter · normal",
      "trigger": "showCounter, below the near-limit threshold",
      "tokens": {
        "counter": "surface.text.gray.muted · typography.fonts.family.code"
      }
    },
    {
      "name": "counter · near limit",
      "trigger": "count >= threshold (threshold UNDEFINED, 90%)",
      "tokens": {
        "counter": "feedback.text.notice.intense",
        "border": "unchanged"
      }
    },
    {
      "name": "loading",
      "trigger": "isLoading",
      "tokens": {
        "spinner": "16px surface.icon.gray.muted, top-right",
        "editableWhileLoading": "UNDEFINED"
      }
    },
    {
      "name": "success",
      "trigger": "validationState=\"success\"",
      "tokens": {
        "border": "interactive.border.gray.default (unchanged)",
        "help": "feedback.text.positive.intense + ✓",
        "successBorderBg": "UNDEFINED"
      }
    },
    {
      "name": "invalid / error",
      "trigger": "validationState=\"error\"",
      "tokens": {
        "border": "feedback.border.negative.intense",
        "errorText": "feedback.text.negative.intense, prefixed \"! \"",
        "focusedInvalidBorder": "UNDEFINED"
      }
    },
    {
      "name": "disabled",
      "trigger": "isDisabled",
      "tokens": {
        "bg": "interactive.background.gray.disabled",
        "border": "interactive.border.gray.default",
        "opacity": "opacity.600 on the whole field"
      }
    },
    {
      "name": "read-only",
      "trigger": "isReadOnly",
      "tokens": {
        "look": "UNDEFINED",
        "drawnAs": "filled tokens, no caret"
      }
    },
    {
      "name": "counter · over limit",
      "trigger": "count > maxLength",
      "tokens": {
        "border": "feedback.border.negative.intense",
        "counterAndMessage": "feedback.border.negative.intense",
        "state": "validationState = error"
      }
    }
  ],
  "behaviour": {
    "input": "<textarea> inside the field, labelled by <label htmlFor>; help / error under it, counter in the footer.",
    "validationTiming": "Validate on blur or submit, not on every keystroke. Error text replaces help text; never show both.",
    "autoGrow": "isAutoGrow (default true): height starts at minRows (or rows), grows one line at a time up to maxRows, then scrolls. isAutoGrow=false: height = rows, content scrolls. minRows / maxRows defaults: UNDEFINED.",
    "loading": "Spinner top-right inside the box; text gets 32px right padding. Editable while loading: UNDEFINED.",
    "characterCount": "Shows count/maxLength when showCounter and maxLength are set. Counting unit and near-limit threshold: UNDEFINED.",
    "pasteOverLimit": "Never block paste. Past the limit the field shows \"! N characters over the limit\" and validationState becomes error. Truncate vs keep: UNDEFINED.",
    "paste": "Kept as-is; not stripped or trimmed.",
    "enter": "Enter and Shift + Enter insert a new line and never submit. Cmd / Ctrl + Enter calls onSubmitShortcut when provided.",
    "error": "Set validationState=\"error\" + errorText; keep the value and focus. After the first blur or submit, re-validate on every change and clear the error as soon as the value is valid.",
    "disabledVsReadOnly": "isDisabled: not focusable, not submitted, no resize. isReadOnly: focusable, submitted, value selectable.",
    "focusOnMount": "autoFocus targets the textarea itself.",
    "resize": "vertical shows the native handle; none hides it. Always none with auto-grow. Default: UNDEFINED."
  },
  "keyboard": [
    {
      "key": "Any character",
      "action": "Types at the caret."
    },
    {
      "key": "Backspace / Delete",
      "action": "Deletes before / after the caret."
    },
    {
      "key": "← → ↑ ↓ · Home / End",
      "action": "Moves the caret; ↑ ↓ move between lines."
    },
    {
      "key": "Cmd / Ctrl + V",
      "action": "Pastes at the caret (see paste over the limit)."
    },
    {
      "key": "Tab / Shift + Tab",
      "action": "Moves focus in and out. Tab never inserts a tab character."
    },
    {
      "key": "Shift + Enter",
      "action": "Inserts a new line, same as Enter."
    },
    {
      "key": "Enter",
      "action": "Inserts a new line. Never submits the form."
    },
    {
      "key": "Cmd / Ctrl + Enter",
      "action": "Optional: calls onSubmitShortcut, e.g. in a comment box."
    }
  ],
  "accessibility": {
    "summary": "The native <textarea> carries the name, description and state.",
    "aria": [
      {
        "element": "<textarea>",
        "attributes": "native multi-line textbox · id linked from <label htmlFor>",
        "when": "Always"
      },
      {
        "element": "<textarea>",
        "attributes": "aria-describedby=\"{messageId} {counterId}\"",
        "when": "Help, counter, success or error text is shown"
      },
      {
        "element": "<textarea>",
        "attributes": "aria-invalid=\"true\"",
        "when": "validationState = \"error\" or over the limit"
      },
      {
        "element": "<textarea>",
        "attributes": "aria-busy=\"true\"",
        "when": "isLoading"
      },
      {
        "element": "<textarea>",
        "attributes": "aria-required=\"true\" · disabled · readOnly",
        "when": "isRequired · isDisabled · isReadOnly"
      },
      {
        "element": "counter",
        "attributes": "aria-live=\"polite\"",
        "when": "Near or over the limit only"
      },
      {
        "element": "resize handle",
        "attributes": "native, no extra ARIA",
        "when": "resize = \"vertical\""
      },
      {
        "element": "spinner <svg>",
        "attributes": "aria-hidden=\"true\"",
        "when": "isLoading"
      },
      {
        "element": "necessity *",
        "attributes": "aria-hidden=\"true\" (required state is on the textarea)",
        "when": "isRequired"
      }
    ]
  },
  "usage": {
    "do": [
      "Always show a visible label; use placeholder only as an example value.",
      "Size the textarea to the expected answer with rows; let it auto-grow up to maxRows.",
      "Show a counter when there is a maxLength, and warn before the limit.",
      "Validate on blur or submit, and replace help text with the error.",
      "Keep Enter as a new line; offer Cmd / Ctrl + Enter only for comment-style submit."
    ],
    "dont": [
      "Use placeholder as the label.",
      "Show help text and error text at the same time.",
      "Silently cut off pasted text past the limit; show the over-limit error.",
      "Block paste.",
      "Use Textarea for single-line answers; use Text Input.",
      "Disable resizing without auto-grow.",
      "Build anything marked UNDEFINED until it has a decision."
    ]
  },
  "example": "<Textarea label=\"Message\" placeholder=\"Type your message here.\" rows={3} maxLength={280} showCounter isRequired helpText=\"Tell us what went wrong.\" />"
}
