Labels should be used to describe the textarea. They can be used visually, and they will also be read out by screen readers when the user is focused on the textarea. This makes it easy for the user to understand the intent of the textarea. Textarea has several ways to assign a label:
label property: used for plaintext labels
label slot: used for custom HTML labels (experimental)
aria-label: used to provide a label for screen readers but adds no visible label
<!-- Label and Label Position --> <!-- Before --> <ion-item> <ion-labelposition="floating">Label:</ion-label> <ion-textarea></ion-textarea> </ion-item> <!-- After --> <ion-item> <ion-textarealabel="Label:"label-placement="floating"></ion-textarea> </ion-item> <!-- Fill --> <!-- Before --> <ion-itemfill="outline"shape="round"> <ion-labelposition="floating">Label:</ion-label> <ion-textarea></ion-textarea> </ion-item> <!-- After --> <!-- Textareas using `fill` should not be placed in ion-item --> <ion-textareafill="outline"shape="round"label="Label:"label-placement="floating"></ion-textarea> <!-- Textarea-specific features on ion-item --> <!-- Before --> <ion-itemcounter="true"> <ion-labelposition="floating">Label:</ion-label> <ion-textareamaxlength="100"></ion-textarea> <divslot="helper">Enter text</div> <divslot="error">Please enter text</div> </ion-item> <!-- After --> <!-- Metadata such as counters and helper text should not be used when a textarea is in an item/list. If you need to provide more context on a textarea, consider using an ion-note underneath the ion-list. --> <ion-textarea label="Label:" counter="true" maxlength="100" helper-text="Enter text" error-text="Please enter text" ></ion-textarea>
<!-- Label and Label Position --> <!-- Before --> <ion-item> <ion-labelposition="floating">Label:</ion-label> <ion-textarea></ion-textarea> </ion-item> <!-- After --> <ion-item> <ion-textarealabel="Label:"labelPlacement="floating"></ion-textarea> </ion-item> <!-- Fill --> <!-- Before --> <ion-itemfill="outline"shape="round"> <ion-labelposition="floating">Label:</ion-label> <ion-textarea></ion-textarea> </ion-item> <!-- After --> <!-- Textareas using `fill` should not be placed in ion-item --> <ion-textareafill="outline"shape="round"label="Label:"labelPlacement="floating"></ion-textarea> <!-- Textarea-specific features on ion-item --> <!-- Before --> <ion-item[counter]="true"> <ion-labelposition="floating">Label:</ion-label> <ion-textareamaxlength="100"></ion-textarea> <divslot="helper">Enter text</div> <divslot="error">Please enter text</div> </ion-item> <!-- After --> <!-- Metadata such as counters and helper text should not be used when a textarea is in an item/list. If you need to provide more context on a textarea, consider using an ion-note underneath the ion-list. --> <ion-textarea label="Label:" [counter]="true" maxlength="100" helperText="Enter text" errorText="Please enter text" ></ion-textarea>
{/* Label and Label Position */} {/* Before */} <IonItem> <IonLabelposition="floating">Label:</IonLabel> <IonTextarea></IonTextarea> </IonItem> {/* After */} <IonItem> <IonTextarealabel="Label:"labelPlacement="floating"></IonTextarea> </IonItem> {/* Fill */} {/* Before */} <IonItemfill="outline"shape="round"> <IonLabelposition="floating">Label:</IonLabel> <IonTextarea></IonTextarea> </IonItem> {/* After */} {/* Textareas using `fill` should not be placed in IonItem */} <IonTextareafill="outline"shape="round"label="Label:"labelPlacement="floating"></IonTextarea> {/* Textarea-specific features on IonItem */} {/* Before */} <IonItemcounter={true}> <IonLabelposition="floating">Label:</IonLabel> <IonTextareamaxlength="100"></IonTextarea> <divslot="helper">Enter text</div> <divslot="error">Please enter text</div> </IonItem> {/* After */} {/* Metadata such as counters and helper text should not be used when a textarea is in an item/list. If you need to provide more context on a textarea, consider using an IonNote underneath the IonList. */} <IonTextarea label="Label:" counter={true} maxlength="100" helperText="Enter text" errorText="Please enter text" ></IonTextarea>
<!-- Label and Label Position --> <!-- Before --> <ion-item> <ion-labelposition="floating">Label:</ion-label> <ion-textarea></ion-textarea> </ion-item> <!-- After --> <ion-item> <ion-textarealabel="Label:"label-placement="floating"></ion-textarea> </ion-item> <!-- Fill --> <!-- Before --> <ion-itemfill="outline"shape="round"> <ion-labelposition="floating">Label:</ion-label> <ion-textarea></ion-textarea> </ion-item> <!-- After --> <!-- Textareas using `fill` should not be placed in ion-item --> <ion-textareafill="outline"shape="round"label="Label:"label-placement="floating"></ion-textarea> <!-- Textarea-specific features on ion-item --> <!-- Before --> <ion-item:counter="true"> <ion-labelposition="floating">Label:</ion-label> <ion-textareamaxlength="100"></ion-textarea> <divslot="helper">Enter text</div> <divslot="error">Please enter text</div> </ion-item> <!-- After --> <!-- Metadata such as counters and helper text should not be used when a textarea is in an item/list. If you need to provide more context on a textarea, consider using an ion-note underneath the ion-list. --> <ion-textarea label="Label:" :counter="true" maxlength="100" helper-text="Enter text" error-text="Please enter text" ></ion-textarea>
The ionChange event is fired when the user modifies the textarea's value. Unlike the ionInput event, the ionChange event is fired when the element loses focus after its value has been modified.
ionFocus
Inputにフォーカスが当たったときに発行されます。
ionInput
The ionInput event is fired each time the user modifies the textarea's value. Unlike the ionChange event, the ionInput event is fired for each alteration to the textarea's value. This typically happens for each keystroke as the user types.
When clearOnEdit is enabled, the ionInput event will be fired when the user clears the textarea by performing a keydown event.