Text Area
Use cases:
- Comments
- Descriptions
- Multi-line text inputs
- Complex searches
Examples
- Genesis
- React
- Angular
Declaration
<rapid-text-area></rapid-text-area>
Usage
@customElement({
name: 'my-element',
template: html`
<rapid-text-area :value=${sync((x) => x.textAreaValue)}>
Sample Text Area
</rapid-text-area>
`,
})
export class MyElement extends GenesisElement {
@observable textAreaValue = '';
textAreaValueChanged() {
console.log(this.textAreaValue);
}
}
Declaration
<rapid-text-area></rapid-text-area>
Usage
export function MyComponent() {
const handleTextAreaChanged = (event) => {
const target = event.target as HTMLInputElement;
console.log(target.value);
};
return (
<rapid-text-area onChange={handleTextAreaChanged}></rapid-text-area>
);
}
Declaration
<rapid-text-area></rapid-text-area>
Usage
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
@Component({
selector: 'my-root',
template: `
<rapid-text-area
(change)="onTextAreaChange($event)"
></rapid-text-area>
`,
styleUrls: ['./my.component.css'],
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppComponent {
onTextAreaChange(event: Event) {
const target = event.target as HTMLInputElement;
console.log(target.value);
}
}
API
Attributes:
Name | Type | Description | Example |
---|---|---|---|
appearance | "filled" | "outline" | Changes the general view of the element; this can be filled or outline |
|
autofocus | boolean | When true, the component will be focused when the page has finished loading |
|
cols | number | Defines the size of the element horizontally. Default: 20 |
|
disabled | boolean | Similar to readonly , but with a blur on the component |
|
formId | string | Associates this component to a form. Form id needs to be passed. If no Id informed, then it will be associated with the ancestor form |
|
maxlength | number | The maximum number of characters allowed |
|
minlength | number | The minimum number of characters allowed |
|
name | string | Defines the name of the element |
|
placeholder | string | Sets placeholder text for the element, which disappears when the user starts inputting |
|
readonly | boolean | If true, the user cannot change the value of this field |
|
resize | "none" | "both" | "vertical" | "horizontal" | Configures which ways the user can resize the text area. Default: none |
|
rows | number | Defines the size of the element vertically. Default: 2 |
|
value | string | The text area content. Use the sync utility to bind the data from the template back to the model. |
|
Properties
This component doesn't have any properties which are not also controlled via attributes.
Slots
Slot | Description |
---|---|
start | Content before the text area input |
end | Content after the text area input |
Parts
Part | Description |
---|---|
label | The label for the text area. |
control | The input for the text area |
field | The text area element |
Events fired
Event | Type | Use | Example |
---|---|---|---|
change | event | Emits a custom change event when the text area content changes. Access the value on the event via .target.value . |
|
Events listened to
This component doesn't listen to any events.
Further details
This component is an implementation of an HTML text-area element.