Your next page is taking shape...

Opening Your Next Page…

Loading the guide and preparing its examples for you to explore. The page will appear here automatically when it’s ready, so you can keep this view open without refreshing.

Made for Preact. Built to be yours.

Forms & Input

Textarea

Textarea captures longer multi-line user input. Make the expected input clear before someone interacts, and keep the current value, help text and validation feedback connected. Import it from @/components/kamod-ui/textarea.

Source · Design reference · API reference · Theming · Styles


Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Installation

Import Textarea from @/components/kamod-ui/textarea.

Install PackagesTerminal
pnpm add @kamod-ch/ui

Copy an example with @kamod-ch/ui or the matching @kamod-ch/ui/… subpath. The code block switches between those two installs. Connect The Global Theme CSS and Tailwind Source Detection before your first render.

Usage

Use Textarea with Field for labels, descriptions, errors, and more modern form layouts.

Import SetupTypeScript
import { Textarea } from "@kamod-ch/ui";

Choose a complete composition from the examples below; required child components and props vary by pattern.

Component Examples & Variants

Explore Textarea in Different Contexts, from the starting pattern to the compositions below. Begin with Basic Textarea, then compare the examples that match your content, state and layout. These are working patterns to adapt, not a list of interchangeable variant values: check the API Reference before using a prop or combining behaviors. Look at the surrounding labels, supporting text and spacing as well as the component itself.

Read the Result and Its Implementation Together. Use each showcase’s Code view to inspect imports and composition, or its Prompt view to prepare a setup or adaptation brief. Try the narrow preview and local theme controls before connecting real data, and use Reset to return an example to its initial state. Keep layout changes in class utilities where appropriate; follow the Component Styles Guide for hierarchy and the Theming Guide for shared surfaces and colors. The Accessibility Notes explain what to preserve when making those changes.

Basic Textarea

Give Longer Input a Clear Purpose. Use Textarea for a short note, comment or feedback response that may span several lines. Its default surface provides the editable area, while a persistent label should explain what kind of answer the field expects.

Choose an initial height that fits the expected answer and keep instructions outside the editable value so they remain available as the user writes.

src/components/TextareaExample.tsx3 lines
import { Textarea } from "@kamod-ch/ui";

export const Example = () => <Textarea placeholder="Write your feedback..." class="max-w-lg" />;

Field + Description

Keep Help Close to the Writing Area. Compose Textarea with Field to keep the label and helper text close to the multiline value. The wrapper organizes the explanation, while the textarea remains the actual editable control associated with that label.

Preserve those associations when adjusting the layout, and explain length or content expectations before users invest time in a long answer.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Disabled + Invalid

Distinguish Unavailable Editing from a Correctable Error. Show disabled state when editing is unavailable and invalid state when the current answer needs correction. Keep the entered text visible in both cases, pairing validation styling with a message that explains how to fix the value.

Keep the entered text available for review and avoid discarding a long response when validation or submission fails.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Textarea Sizes

Choose a Comfortable Starting Area. Compare the textarea size options using the same content and surrounding field layout. A compact setting may suit short notes, while a roomier one can give longer responses enough visible space for review.

Test multiline content and error messages at narrow widths, and avoid using a small initial height as an arbitrary limit on the answer.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Character Counter

Derive the Count from the Submitted Value. Derive a character count from the textarea's current value and display it beside the relevant limit. This gives immediate guidance as the user types, while the form's validation decides how an over-limit answer is handled.

Explain how much text is allowed, decide what happens at the boundary and avoid announcing every keystroke in a way that overwhelms assistive-technology users.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Auto-Resize

Let the Field Grow without Losing Page Context. Resize the textarea in response to input when the field should grow with the answer. The example illustrates that behavior around an ordinary multiline control; choose sensible bounds so a long response does not consume the entire screen.

Recalculate after programmatic changes as well as typing, and avoid repeated layout work that makes editing feel sluggish.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Production Field Pattern

Coordinate Label, Help, Count and Error Around One Value. Combine a label, hint, validation message and live character count around one textarea value. Each element answers a different question: what to write, how to format it, what needs correction and how much space remains.

Keep validation associated with the textarea, preserve the user's text after failure and ensure the character count agrees with the actual accepted limit.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Textarea + Action

Make Sending Distinct from Editing. Place a send or submit action beside the textarea when composing a message is one focused task. Keep the editable content prominent and make the action's pending and error behavior part of the same message workflow.

Keep pending and error states clear, prevent accidental duplicate sends and decide deliberately whether Enter inserts a line break or performs an application shortcut.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width
API reference

Props and Data

Configure Textarea using the contracts below. Read the documented options alongside the Source Definitions to understand which values your application supplies and which details the component owns. Start with a prop or helper, then follow its type link to inspect the declaration without leaving the page.

Props, slots and variants for this component.

API reference
Your API, from source

Type cards are extracted from this checkout’s TypeScript source at build time. Props inherited through HTMLAttributes, Omit or variant helpers remain references in those declarations; their fields are not flattened here. Match the reference to your installed version, and check a package’s exports before writing an import type. A type exported by a source file is not necessarily re-exported by @kamod-ch/ui.

Component Props

Read each option with its owning component. The
marker identifies required fields verified in that declaration. A ? means a field can be omitted; it does not promise a fallback value. Existing documented defaults remain alongside the descriptions. For callbacks, check the argument and return types before connecting your own state or services.
@kamod-ch/ui/textarea2.1 KB min · 0.8 KB gzipSignals: none

Textarea

TextareaProps

Textarea documented props
Prop / typeDescription
class
string | SignalLike<string | undefined>TextareaProps

Configure class for Textarea. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
disabled
boolean | SignalLike<boolean | undefined>TextareaProps

Configure disabled for Textarea. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
size
"sm" | "md" | "lg"TextareaProps

Configure size for Textarea. Compare its accepted type with the Usage Guidance before supplying a value.

Default
"md"

Data Type Reference

Expand a card to inspect and copy the exact declaration. The code header identifies its repository file; follow imported or inherited types in the Implementation Source when you need the complete dependency chain. Required-field summaries cover fields declared directly in that type. Source-only helpers and inferred schema outputs describe the local implementation, not additional props you can pass to every component.

Textarea Props

Declaration
TextareaProps
Exported Source Declaration from Textarea.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of TextareaProps before adapting it.

Accessibility

Build the Complete Interaction, Including the Parts Outside Textarea. The notes below distinguish the current implementation from the labels, content and behavior your application supplies. Start with the Live Preview, check the Props and Data Reference, and test the finished composition with real content rather than assuming that an unchanged visual example covers every use case.

Built-in Behavior and Defaults

Textarea keeps native multiline editing and forwards textarea attributes. Styling for aria-invalid communicates the visual error state; it does not create an error description or a character-limit announcement.

Labels and Relationships

Use a visible label and describe the expected content, length and privacy boundaries before entry. Give help and error text stable IDs. If showing a remaining-character count, connect it as a description and avoid announcing every keystroke through an assertive live region.

Keyboard and Focus

Allow Enter to create a new line unless a clearly explained application interaction requires otherwise. Preserve selection, paste and undo. If a chat composer uses a submission shortcut, describe the shortcut and retain a normal Send button.

States and Integration Details

Do not fix the height so tightly that long text or enlarged fonts become unreadable. Distinguish a maximum enforced by maxLength from a recommended length, and preserve the entered draft when a request fails.

Verify the Complete Interaction

Check Behavior as Well as Markup. Work through these scenarios in the application where the component will be used. Automated checks can help find structural problems; also review the reading experience with a screen reader, keyboard focus and the actual feedback from your application.

  1. Read the label, instructions and error with the field focused; a placeholder alone must not carry the task.
  2. Paste several paragraphs and use the keyboard to reach both the start and end of the text.
  3. Increase text size and resize the viewport; keep the caret, validation and submission action reachable.

Recheck the result after changing Theme Tokens, translations or class overrides. Include text enlargement, narrow layouts and reduced-motion settings where animation is present. Inspect the Component Source when a behavior differs from your expectation; a role or state attribute does not implement keyboard interaction by itself.

For background, read the WAI-ARIA Authoring Guidance and Keyboard Interface Guidance. These explain the patterns; verify browser and assistive-technology behavior for the implementation and audience you actually support.

Take the Next Useful Step

You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.

Connect the Foundation

Return to Choose and Compose Components to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.

Build the Surrounding Screen

Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.

Make the Result Hold Up

Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.

Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.