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
With Counter
With Error
Read Only
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
| Variant | What it is |
|---|---|
| default | Grows with rows, user can resize vertically. |
| counter | maxLength shows "N / max" under the field, announced politely. |
| error | Red border and message. |
| readOnly | Lock 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
| Prop | Type | Default | Description |
|---|---|---|---|
label * | string | — | Visible label; required |
rows | number | 3 | Visible rows |
maxLength | number | none | Maximum characters; shows a live "n / max" counter |
value | string | undefined (uncontrolled) | Controlled value |
defaultValue | string | "" | Initial value (uncontrolled) |
onChange | (value: string, event: ChangeEvent<HTMLTextAreaElement>) => void | none | Called with the value and the change event |
error | string | none | Error message (as TextField) |
helper | string | none | Muted hint under the field (as TextField) |
required | boolean | false | Red asterisk plus aria-required (as TextField) |
readOnly | boolean | false | Read-only lock state (as TextField) |
lockMessage | string | 'Your role can view but not edit' | Lock line text when readOnly |
style | CSSProperties | — | 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>
| Kind | Name | Description |
|---|---|---|
| attribute | label | Visible label; required |
| attribute | rows | Visible rows; default 3 |
| attribute | max-length / maxLength | Maximum characters; shows a live "n / max" counter; default none |
| attribute | value | Controlled value; default undefined (uncontrolled) |
| attribute | default-value / defaultValue | Initial value (uncontrolled); default "" |
| attribute | error | Error message (as TextField); default none |
| attribute | helper | Muted hint under the field (as TextField); default none |
| attribute | required | Red asterisk plus aria-required (as TextField); default false |
| attribute | read-only / readOnly | Read-only lock state (as TextField); default false |
| attribute | lock-message / lockMessage | Lock line text when readOnly; default 'Your role can view but not edit' |
| property / JSON attribute | style | Inline style of the root |
| attribute | default-checked / defaultChecked | |
| attribute | auto-focus / autoFocus | |
| attribute | disabled | |
| attribute | name | |
| attribute | placeholder | |
| attribute | auto-complete / autoComplete | |
| event | co-change | Called with the value and the change event; default none (React: onChange) |
| event | co-input | (React: onInput) |