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
While plaintext labels should be passed in via the label property, if custom HTML is needed, it can be passed through the label slot instead.
Note that this feature is considered experimental because it relies on a simulated version of Web Component slots. As a result, the simulated behavior may not exactly match the native slot behavior.
<!-- 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>