Text Area
A multi-line input that enables user to type in text information.
Importing
To use the text area component, first you need to register the component inside the page. You can register the component manually by importing the register function:
ts
import { register } from "@tapsioss/web-components/text-area";
register(); // Now the text area component is ready to use!
ts
import { registerTextArea } from "@tapsioss/web-components";
registerTextArea(); // Now the text area component is ready to use!
Also you can automatically register the component by importing it with the following approach:
ts
import "@tapsioss/web-components/text-area/element";
TIP
If you want to use all the component in your app, you can call registerAll
at the root of your project.
ts
import { registerAll } from "@tapsioss/web-components";
registerAll(); // All the components are now available
In the React package, you can easily add the component using the following code:
ts
import { TextArea } from "@tapsioss/react-components";
Component Usage
html
<tapsi-text-area></tapsi-text-area>
tsx
<TextArea />
Properties
Name | Attribute Name | Description | Type | Default Value |
---|---|---|---|---|
rows | rows | The number of rows to display for the text input. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#rows | number | 2 |
minRows | min-rows | Minimum number of rows to display. If specified will automatically adjust the height. | number | NaN |
cols | cols | The number of cols to display for the text input. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#cols | number | 20 |
inputMode | inputMode | Hints at the type of data that might be entered by the user while editing the element or its contents. This allows a browser to display an appropriate virtual keyboard. https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode | string | "" |
maxLength | maxlength | The maximum number of characters a user can enter into the text input. Set to -1 for none. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#maxlength | number | -1 |
minLength | minlength | The minimum number of characters a user can enter into the text input. Set to -1 for none. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#minlength | number | -1 |
placeholder | placeholder | Defines the text displayed in the text input when it has no value. Provides a brief hint to the user as to the expected type of data that should be entered into the control. https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/placeholder | string | "" |
readOnly | - | Indicates whether or not a user should be able to edit the text input's value. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#readonly | boolean | false |
autocomplete | autocomplete | Describes what, if any, type of autocomplete functionality the input should provide. https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete | AutoFill | "" |
supportingText | supporting-text | Conveys additional information below the text input, such as how it should be used. | string | "" |
error | error | Gets or sets whether or not the text input is in a visually invalid state. This error state overrides the error state controlled by reportValidity() . | boolean | false |
errorText | error-text | The error message that replaces supporting text when error is true. IferrorText is an empty string, then the supporting text will continue toshow. This error message overrides the error message displayed by reportValidity() . | string | "" |
label | label | The label of the text input. - If the hideLabel property is true, the label will be hidden visuallybut still accessible to screen readers. - Otherwise, a visible label element will be rendered. https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label | string | "" |
hideLabel | hide-label | Whether to hide the label or not. | boolean | false |
rounded | rounded | Whether the input is rounded or not. | boolean | false |
size | size | The size of the input. | "sm" | "md" | "md" |
noActiveBorder | no-active-border | Whether to show the active border around the input or not. | boolean | false |
value | value | The current value of the input. It is always a string. | string | "" |
required | required | Indicates that the user must specify a value for the input before the owning form can be submitted and will render an error state when reportValidity() is invoked when value is empty.https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required | boolean | false |
labelledBy | labelledby | Identifies the element (or elements) that labels the input. https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-labelledby | string | "" |
autofocus | autofocus | Indicates that the element should be focused on page load. https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus | boolean | false |
Methods
Name | Description | Parameters |
---|---|---|
reset | Reset the text field to its default value. |
Slots
Name | Value | Description |
---|---|---|
LEADING_ICON | leading-icon | the trailing slot of the input |
TRAILING | trailing | the trailing slot of the input |
TIP
The value of slots are available for developer as JavaScript Variables:
ts
// Option 1
import { TextAreaSlots } from "@tapsioss/web-components";
// Option 2
import { Slots } from "@tapsioss/web-components/text-area";
ts
// Option 1
import { TextAreaSlots } from "@tapsioss/react-components";
// Option 2
import { Slots } from "@tapsioss/react-components/TextArea";
Events
Name | Description | Type | Bubbles | Cancelable |
---|---|---|---|---|
change | Fires when the user modifies the element's value. Unlike the input event, the change event is not necessarily fired for each alteration to an element's value . | Event | ✅ | ❌ |
input | Fires when the value of an input element has been changed as a direct result of a user action. | Event | ✅ | ❌ |