|
| 1 | +## Features |
| 2 | + |
| 3 | +- Multi-line text input that grows automatically as the user types. |
| 4 | +- Optional label, description, indicator, and helper message. |
| 5 | +- Character count display — shows `n` or `n / maxLength` when a limit is set. |
| 6 | +- Invalid state with error border and background. |
| 7 | +- Read-only state for non-editable values that can still be selected and copied. |
| 8 | + |
| 9 | +## Usage |
| 10 | + |
| 11 | +```tsx |
| 12 | +import { TextArea } from '@equinor/eds-mobile-components' |
| 13 | + |
| 14 | +const [value, setValue] = useState('') |
| 15 | + |
| 16 | +<TextArea |
| 17 | + label="Comments" |
| 18 | + placeholder="Enter your comments" |
| 19 | + value={value} |
| 20 | + onChangeText={setValue} |
| 21 | +/> |
| 22 | +``` |
| 23 | + |
| 24 | +## Examples |
| 25 | + |
| 26 | +### With description and helper message |
| 27 | + |
| 28 | +```tsx |
| 29 | +<TextArea |
| 30 | + label="Observations" |
| 31 | + description="Describe what you observed on site." |
| 32 | + helperMessage="Required before submitting" |
| 33 | + placeholder="Enter observations" |
| 34 | + value={value} |
| 35 | + onChangeText={setValue} |
| 36 | +/> |
| 37 | +``` |
| 38 | + |
| 39 | +### Character count |
| 40 | + |
| 41 | +Pass `showCharacterCount` to show a live count below the field. Combine with `maxLength` to show `n / max`. |
| 42 | + |
| 43 | +```tsx |
| 44 | +<TextArea |
| 45 | + label="Notes" |
| 46 | + showCharacterCount |
| 47 | + maxLength={500} |
| 48 | + value={value} |
| 49 | + onChangeText={setValue} |
| 50 | +/> |
| 51 | +``` |
| 52 | + |
| 53 | +### Invalid |
| 54 | + |
| 55 | +```tsx |
| 56 | +<TextArea |
| 57 | + label="Description" |
| 58 | + invalid |
| 59 | + helperMessage="This field is required" |
| 60 | + value={value} |
| 61 | + onChangeText={setValue} |
| 62 | +/> |
| 63 | +``` |
| 64 | + |
| 65 | +### Read-only |
| 66 | + |
| 67 | +```tsx |
| 68 | +<TextArea |
| 69 | + label="Submitted notes" |
| 70 | + value="These notes were submitted and cannot be edited." |
| 71 | + readOnly |
| 72 | +/> |
| 73 | +``` |
| 74 | + |
| 75 | +### Disabled |
| 76 | + |
| 77 | +```tsx |
| 78 | +<TextArea |
| 79 | + label="Comments" |
| 80 | + placeholder="Not available" |
| 81 | + disabled |
| 82 | +/> |
| 83 | +``` |
| 84 | + |
| 85 | +## Props |
| 86 | + |
| 87 | +| Prop | Type | Default | Description | |
| 88 | +|---|---|---|---| |
| 89 | +| `label` | `string` | — | Label displayed above the field | |
| 90 | +| `indicator` | `string` | — | Inline text after the label, e.g. `"(Optional)"` | |
| 91 | +| `description` | `string` | — | Descriptive text below the label | |
| 92 | +| `helperMessage` | `string` | — | Message shown below the field | |
| 93 | +| `invalid` | `boolean` | `false` | Error state — red border and background | |
| 94 | +| `disabled` | `boolean` | `false` | Disables all interaction | |
| 95 | +| `readOnly` | `boolean` | `false` | Prevents editing; value can still be selected and copied | |
| 96 | +| `showCharacterCount` | `boolean` | `false` | Shows a character count below the field | |
| 97 | +| `maxLength` | `number` | — | Maximum character count; shows `n / max` when combined with `showCharacterCount` | |
| 98 | + |
| 99 | +Also accepts all React Native [`TextInputProps`](https://reactnative.dev/docs/textinput#props), excluding `multiline`, `editable`, `readOnly`, and `scrollEnabled` which are managed internally. |
| 100 | + |
| 101 | +## Accessibility |
| 102 | + |
| 103 | +- Reports `disabled` state to assistive technology via `accessibilityState`. |
| 104 | +- `accessibilityLabel` defaults to the `label` prop when not provided. |
| 105 | +- `accessibilityHint` defaults to a concatenation of `description` and `helperMessage` when not provided. |
| 106 | +- When `showCharacterCount` and `maxLength` are both set, the count is read aloud by screen readers once the user reaches 80% of the limit. |
| 107 | +- Always provide a `label` or `accessibilityLabel`. |
| 108 | + |
| 109 | +## Related components |
| 110 | + |
| 111 | +- `TextField` — single-line labelled input with the same field structure. |
| 112 | +- `Input` — bare single-line input without label or helper message. |
0 commit comments