Using Ionic 3.19.1. I want to create ion-items with one icon on the left, two lines on the middle and one ion-toggle at the end.
With two icons, it works perfectly:
I did that with this code:
<ion-list>
<ion-item>
<ion-icon name="american-football" item-start></ion-icon>
<h2>prefs_transversal_products</h2>
<p>prefs_transversal_products_desc</p>
<!-- <ion-toggle color="secondary" item-end></ion-toggle> -->
<ion-icon name="american-football" item-end></ion-icon>
</ion-item>
</ion-list>
But if I enable the ion-toggle, the two lines of text disappear like this:
What am I missing?
Thank you.
Most of the time when you want to add more than one element of the same kind in Ionic, the best way is to use list items. The class that is used for multiple toggles is the item-toggle.
The class that is used for multiple toggles is the item-toggle. The next example shows how to create a list for toggles. The first one and the second one are checked. All the Ionic color classes can be applied to the toggle element.
Thanks for the issue! The lines attribute works on both the ion-list ion-item component. Our documentation for that is here: If you could point to where our documentation is incorrect that would be helpful. I'm not necessarily saying the documentation isn't correct.
The value of a toggle is analogous to the value of a <input type="checkbox"> , it's only used when the toggle participates in a native <form>. Emitted when the toggle loses focus.
I can reproduce your issue, not quite sure what's going on there. Might be a bug.
Anyway, wrapping your text in an <ion-label>
solves the problem for me:
<ion-list>
<ion-item text-wrap>
<ion-icon name="american-football" item-start></ion-icon>
<ion-label>
<h2>prefs_transversal_products</h2>
<p>prefs_transversal_products_desc</p>
</ion-label>
<ion-toggle color="secondary" item-end></ion-toggle>
</ion-item>
</ion-list>
See the docs for advanced usage of <ion-item>
for additional info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With