Textarea
Multiline text input with resizing, helper and error text, and a character counter.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
value | string | — | Current text. Set this property to update the value programmatically. |
name | string | — | Name forwarded to the native control. |
label | string | — | Accessible name for the native textarea. |
aria-label | string | null | null | Accessible name forwarded from the host. |
placeholder | string | — | Hint shown when empty. |
rows | number | 3 | Visible number of text lines. |
cols | number | 20 | Native width hint, used when no CSS width is set. |
resize | 'none' | 'vertical' | 'horizontal' | 'both' | vertical | Allowed user resize directions. |
wrap | 'soft' | 'hard' | 'off' | soft | Native line wrapping mode. |
autocomplete | string | — | Browser autocomplete hint. |
disabled | boolean | false | Prevents editing and removes the control from keyboard navigation. |
readonly | boolean | false | Prevents editing while allowing selection. |
required | boolean | false | Requires a nonempty value for native validation. |
maxlength | number | -1 | Maximum character count; -1 means unlimited. |
minlength | number | -1 | Minimum character count; -1 means no minimum. |
error | boolean | false | Displays the error border and error text. |
error-text | string | — | Message displayed when error is true. |
help | string | — | Helper text below the control. |
Slots
| Name | Description |
|---|---|
supporting-text | Rich helper content below the field; error-text takes precedence when invalid. |
Events
| Name | Type | Description |
|---|---|---|
input | InputEvent | Fired on each edit, after value is updated. |
change | Event | Fired when an edit is committed. |
select | Event | Fired when text is selected. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
textarea | The native textarea control. |
supporting-text | Container wrapping the supporting-text slot or generated help and validation fallback. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-textarea__container--min-height | pixel | 80px | |
--c2-textarea__container--padding | padding | 10px 12px | |
--c2-textarea__container--border | border | 1px solid #bcbcc6 | |
--c2-textarea__container--border-radius | border-radius | 6px | |
--c2-textarea__container--background | color | #ffffff | |
--c2-textarea__container--color | color | #18181b | |
--c2-textarea__container--font-family | font-family | inherit | |
--c2-textarea__container--font-size | font-size | 14px | |
--c2-textarea__container--line-height | pixel | 20px | |
--c2-textarea__container__hover--border | border | 1px solid #a1a1aa | |
--c2-textarea__container__focus--border | border | 1px solid #476ef9 | |
--c2-textarea__container__focus--outline | outline | none | |
--c2-textarea__container__error--border | border | 1px solid #dc2626 | |
--c2-textarea__container__error__focus--outline | outline | none | |
--c2-textarea__container__read-only--background | color | #fafafa | |
--c2-textarea__container__disabled--opacity | opacity | 0.38 | |
--c2-textarea__placeholder--color | color | #71717a | |
--c2-textarea__supporting-text--gap | pixel | 4px | |
--c2-textarea__supporting-text--font-size | font-size | 12px | |
--c2-textarea__supporting-text--line-height | pixel | 16px | |
--c2-textarea__supporting-text--color | color | #71717a | |
--c2-textarea__supporting-text__error--color | color | #dc2626 | |