Developers can use the alignment property to control how the label and control are aligned on the cross axis. This property mirrors the flexbox align-items property.
note
Stacked checkboxes can be aligned using the alignment property. This can be useful when the label and control need to be centered horizontally.
<!-- Basic --> <!-- Before --> <ion-item> <ion-label>Checkbox Label</ion-label> <ion-checkbox></ion-checkbox> </ion-item> <!-- After --> <ion-item> <ion-checkbox>Checkbox Label</ion-checkbox> </ion-item> <!-- Fixed Labels --> <!-- Before --> <ion-item> <ion-labelposition="fixed">Checkbox Label</ion-label> <ion-checkbox></ion-checkbox> </ion-item> <!-- After --> <ion-item> <ion-checkboxlabel-placement="fixed">Checkbox Label</ion-checkbox> </ion-item> <!-- Checkbox at the start of line, Label at the end of line --> <!-- Before --> <ion-item> <ion-labelslot="end">Checkbox Label</ion-label> <ion-checkbox></ion-checkbox> </ion-item> <!-- After --> <ion-item> <ion-checkboxlabel-placement="end">Checkbox Label</ion-checkbox> </ion-item>
<!-- Basic --> <!-- Before --> <ion-item> <ion-label>Checkbox Label</ion-label> <ion-checkbox></ion-checkbox> </ion-item> <!-- After --> <ion-item> <ion-checkbox>Checkbox Label</ion-checkbox> </ion-item> <!-- Fixed Labels --> <!-- Before --> <ion-item> <ion-labelposition="fixed">Checkbox Label</ion-label> <ion-checkbox></ion-checkbox> </ion-item> <!-- After --> <ion-item> <ion-checkboxlabelPlacement="fixed">Checkbox Label</ion-checkbox> </ion-item> <!-- Checkbox at the start of line, Label at the end of line --> <!-- Before --> <ion-item> <ion-labelslot="end">Checkbox Label</ion-label> <ion-checkbox></ion-checkbox> </ion-item> <!-- After --> <ion-item> <ion-checkboxlabelPlacement="end">Checkbox Label</ion-checkbox> </ion-item>
{/* Basic */} {/* Before */} <IonItem> <IonLabel>Checkbox Label</IonLabel> <IonCheckbox></IonCheckbox> </IonItem> {/* After */} <IonItem> <IonCheckbox>Checkbox Label</IonCheckbox> </IonItem> {/* Fixed Labels */} {/* Before */} <IonItem> <IonLabelposition="fixed">Checkbox Label</IonLabel> <IonCheckbox></IonCheckbox> </IonItem> {/* After */} <IonItem> <IonCheckboxlabelPlacement="fixed">Checkbox Label</IonCheckbox> </IonItem> {/* Checkbox at the start of line, Label at the end of line */} {/* Before */} <IonItem> <IonLabelslot="end">Checkbox Label</IonLabel> <IonCheckbox></IonCheckbox> </IonItem> {/* After */} <IonItem> <IonCheckboxlabelPlacement="end">Checkbox Label</IonCheckbox> </IonItem>
<!-- Basic --> <!-- Before --> <ion-item> <ion-label>Checkbox Label</ion-label> <ion-checkbox></ion-checkbox> </ion-item> <!-- After --> <ion-item> <ion-checkbox>Checkbox Label</ion-checkbox> </ion-item> <!-- Fixed Labels --> <!-- Before --> <ion-item> <ion-labelposition="fixed">Checkbox Label</ion-label> <ion-checkbox></ion-checkbox> </ion-item> <!-- After --> <ion-item> <ion-checkboxlabel-placement="fixed">Checkbox Label</ion-checkbox> </ion-item> <!-- Checkbox at the start of line, Label at the end of line --> <!-- Before --> <ion-item> <ion-labelslot="end">Checkbox Label</ion-label> <ion-checkbox></ion-checkbox> </ion-item> <!-- After --> <ion-item> <ion-checkboxlabel-placement="end">Checkbox Label</ion-checkbox> </ion-item>
How to control the alignment of the checkbox and label on the cross axis. "start": The label and control will appear on the left of the cross axis in LTR, and on the right side in RTL. "center": The label and control will appear at the center of the cross axis in both LTR and RTL.
Where to place the label relative to the checkbox. "start": The label will appear to the left of the checkbox in LTR and to the right in RTL. "end": The label will appear to the right of the checkbox in LTR and to the left in RTL. "fixed": The label has the same behavior as "start" except it also has a fixed width. Long text will be truncated with ellipses ("..."). "stacked": The label will appear above the checkbox regardless of the direction. The alignment of the label can be controlled with the alignment property.