Skip to main content

TextArea

BasicInputs<co-text-area>

TextArea takes multi-line text such as a reason for visit, a denial note or a message to the patient.

import { TextArea } from 'health-components';

Examples​

Showcase​

Storybook

With Counter​

Storybook

With Error​

Storybook

Read Only​

Storybook

Usage​

<TextArea label="Reason for Visit" required maxLength={500} value={reason} onChange={setReason} />

When to use​

  • Notes, reasons, appeal letters, messages.

When not to use​

  • Structured clinical data that should be coded (diagnoses, allergies): use Combobox.

Variants and states​

VariantWhat it is
defaultGrows with rows, user can resize vertically.
countermaxLength shows "N / max" under the field, announced politely.
errorRed border and message.
readOnlyLock state like TextField.

Accessibility​

  • The counter is aria-live polite so typing is not interrupted.

Do and don't​

  • Do: Reason for Cancellation with a 500 character limit.
  • Don't: Free text for the diagnosis on a claim line.

Props​

PropTypeDefaultDescription
label *string—Visible label; required
rowsnumber3Visible rows
maxLengthnumbernoneMaximum characters; shows a live "n / max" counter
valuestringundefined (uncontrolled)Controlled value
defaultValuestring""Initial value (uncontrolled)
onChange(value: string, event: ChangeEvent<HTMLTextAreaElement>) => voidnoneCalled with the value and the change event
errorstringnoneError message (as TextField)
helperstringnoneMuted hint under the field (as TextField)
requiredbooleanfalseRed asterisk plus aria-required (as TextField)
readOnlybooleanfalseRead-only lock state (as TextField)
lockMessagestring'Your role can view but not edit'Lock line text when readOnly
styleCSSProperties—Inline style of the root

Also accepts native attributes, including defaultChecked, autoFocus, onInput, disabled, name, placeholder, autoComplete, plus className and event handlers on the root element.

Angular, Vue and HTML​

Register the elements once (Angular guide), then use <co-text-area>. Attributes take strings; arrays and objects are set as properties (Angular [prop], Vue :prop) or as JSON attributes. Callbacks are DOM events with the value in event.detail.

Angular template
<co-text-area label="…" rows="…" [style]="style" (co-change)="onChange($event.detail)"></co-text-area>
KindNameDescription
attributelabelVisible label; required
attributerowsVisible rows; default 3
attributemax-length / maxLengthMaximum characters; shows a live "n / max" counter; default none
attributevalueControlled value; default undefined (uncontrolled)
attributedefault-value / defaultValueInitial value (uncontrolled); default ""
attributeerrorError message (as TextField); default none
attributehelperMuted hint under the field (as TextField); default none
attributerequiredRed asterisk plus aria-required (as TextField); default false
attributeread-only / readOnlyRead-only lock state (as TextField); default false
attributelock-message / lockMessageLock line text when readOnly; default 'Your role can view but not edit'
property / JSON attributestyleInline style of the root
attributedefault-checked / defaultChecked
attributeauto-focus / autoFocus
attributedisabled
attributename
attributeplaceholder
attributeauto-complete / autoComplete
eventco-changeCalled with the value and the change event; default none (React: onChange)
eventco-input (React: onInput)