Textarea component is a form element which allows the user to input multiple lines of text.
The textarea component comes in three sizes: small, and large. The default size is sm.
The textarea component comes in three statuses: default, success, and error. The default status is default.
import { DapDSTextarea } from 'dap-design-system'
import { DapDSTextareaReact } from 'dap-design-system/react'
For optimal bundle sizes, use the tree-shakeable import syntax:
import { DapDSTextarea } from 'dap-design-system/components'
| Property | Type | Default | Description |
|---|---|---|---|
hideCounter | boolean | false | Hide character counter. |
minlength | number | The minimum length of the textarea. | |
maxlength | number, undefined | The maximum length of the textarea. | |
rows | number, undefined | 6 | The number of rows in the textarea. |
cols | number, undefined | The number of columns in the textarea. | |
placeholder | string | '' | The placeholder of the textarea. |
wrap | 'hard', 'soft' | Indicates how the control should wrap the value for form submission. | |
size | 'xs', 'sm' , 'lg' | The size of the textarea. Default is md. | |
disabled | boolean | The disabled state of the textarea. | |
value | string | The value of the textarea. | |
tooltip | string | The tooltip of the textarea. | |
tooltipPlacement | 'top', 'right' , 'bottom' , 'left' | The tooltip placement of the textarea. | |
status | InputStatus | The status of the textarea. Can be success or error. | |
readonly | boolean | The readonly state of the textarea. | |
required | boolean | The required state of the textarea. | |
label | string | The label of the textarea. | |
description | string | The description of the textarea. | |
feedback | string | The feedback of the textarea. | |
feedbackType | 'negative', 'positive' , 'warning' | The feedback type of the textarea. Can be negative, positive, or warning. | |
optional | boolean | The optional state of the textarea. | |
optionalLabel | string | The optional label of the textarea. | |
subtle | boolean | The weight of the label. Default is false | |
autofocus | boolean | The autofocus state of the textarea. |
| Name | Description |
|---|---|
feedback-icon | The custom icon of the feedback. |
| Event Name | Description | Type |
|---|---|---|
dds-count-change | Fires when the count of the textarea changes. | {value: number } |
dds-change | Fired when the textarea value changes. | {value: string } |
dds-input | Fired when the textarea value changes. | {value: string } |
dds-keydown | Fired when a key is pressed down. | {value: string, originalEvent: Event } |
dds-blur | Fired when the textarea loses focus. | {void } |
dds-focus | Emitted when the textarea gains focus. | {void } |
dds-select | Emitted when select text in textarea. | {value: string } |
| Part Name | Description |
|---|---|
base | The main textarea container. |
input | The native input of the textarea. |
counter | The counter of the textarea. |
counter-base | The base of the counter. |
feedback | The feedback of the textarea. |
feedback-base | The base of the feedback. |
feedback-text | The text of the feedback. |
feedback-icon | The icon of the feedback. |
You can style CSS parts using the ::part() pseudo-element selector:
/* Target a specific part */
.my-custom-dap-ds-textarea::part(base) {
/* Your custom styles */
}
/* Target multiple parts */
.my-custom-dap-ds-textarea::part(base),
.my-custom-dap-ds-textarea::part(input) {
/* Shared styles */
}
Example usage:
<dap-ds-textarea class="my-custom-dap-ds-textarea">
Textarea
</dap-ds-textarea>
.my-custom-dap-ds-textarea::part(base) {
border-radius: 12px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
CSS parts allow you to style internal elements of the component while maintaining encapsulation. Learn more in our styling guide.
| Property Name | Description |
|---|---|
--dds-textarea-min-rows | Minimum number of rows in the textarea. Default is 2. |
--dds-textarea-spacing | Gap between elements in the textarea container. Default is var(--dds-spacing-200). |
--dds-textarea-gap | Gap between elements in the textarea container. Default is var(--dds-spacing-200). |
--dds-textarea-margin-top | Top margin of the textarea. Default is var(--dds-spacing-200). |
--dds-textarea-padding | Padding of the textarea control. Default is var(--dds-spacing-200) var(--dds-spacing-300). |
--dds-textarea-border-width | Border width of the textarea. Default is var(--dds-border-width-base). |
--dds-textarea-border-color | Border color of the textarea. Default is var(--dds-border-neutral-base). |
--dds-textarea-background | Background color of the textarea. Default is var(--dds-fields-background-default). |
--dds-textarea-color | Text color of the textarea. Default is var(--dds-text-neutral-base). |
--dds-textarea-border-radius | Border radius of the textarea. Default is var(--dds-radius-base). |
--dds-textarea-disabled-bg | Background color when disabled. Default is var(--dds-fields-background-disabled). |
--dds-textarea-disabled-color | Text color when disabled. Default is var(--dds-text-neutral-disabled). |
--dds-textarea-readonly-bg | Background color when readonly. Default is var(--dds-fields-background-read-only). |
--dds-textarea-readonly-color | Text color when readonly. Default is var(--dds-text-neutral-subtle). |
--dds-textarea-error-border | Border color when in error state. Default is var(--dds-border-negative-base). |
--dds-textarea-success-border | Border color when in success state. Default is var(--dds-border-positive-base). |
CSS custom properties (CSS variables) can be set directly on the component or in your stylesheet:
Method 1: Inline styles (Quick customization)
<dap-ds-textarea
style="--dds-textarea-min-rows: value; --dds-textarea-spacing: value;">
Textarea
</dap-ds-textarea>
Method 2: CSS classes (Reusable styles)
.my-custom-dap-ds-textarea {
--dds-textarea-min-rows: value;
--dds-textarea-spacing: value;
--dds-textarea-gap: value;
}
<dap-ds-textarea class="my-custom-dap-ds-textarea">
Textarea
</dap-ds-textarea>
Method 3: Global theme customization
/* Apply to all instances */
dap-ds-textarea {
--dds-textarea-min-rows: value;
--dds-textarea-spacing: value;
}
CSS custom properties inherit through the Shadow DOM, making them perfect for theming. Changes apply immediately without rebuilding.