Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to wordwrap a long string in ion-item

IONIC has two problems about word-wrap in ion-item:

  1. String would be truncated by the dots appended at the end, how to show full content without dots ?
  2. Automatic line breaks and responsive are not working in Firefox (Chrome is ok), how to fix this problem in Firefox ?
<div class="row responsive-sm">
    <div class="col">
        <div class="item item-body">
            <ion-item class="wrap" style="word-wrap: break-word; word-break: break-all;">
            #fashion #fashion #fashion #fashion #fashion #fashion #fashion #fashion #fashion #fashion #fashion #fashion #fashion #fashion #fashion #fashion #fashion #fashion 
            </ion-item>
        </div>
    </div>
</div>

Here is Full HTML to show the problem codepen

like image 295
DinDin Avatar asked Sep 01 '15 15:09

DinDin


People also ask

How do you wrap a long string in HTML?

You can wrap a long string, which does not have any whitespace character by using the CSS word-wrap property, or overflow-wrap, if you use CSS3.


3 Answers

For ionic 1:

Add item-text-wrap class to item.

<ion-item class="item-text-wrap">
  some long string
</ion-item>

For ionic 2:

Add text-wrap attribute to item.

<ion-item text-wrap>
  some long string
</ion-item>
like image 65
Mudasser Ajaz Avatar answered Oct 13 '22 17:10

Mudasser Ajaz


In Ionic 2, use the text-wrap attribute

<ion-item text-wrap>
  text here wraps to multiple lines
</ion-item>
like image 105
Aaron Broad Avatar answered Oct 13 '22 19:10

Aaron Broad


For Ionic 4, use text-wrap on your ion-label element, like so:

<ion-item>
    <ion-label text-wrap>
         Multiline text that should wrap when it is too long
         to fit on one line in the item.
    </ion-label>
  </ion-item>

UPDATE: 10/30/2019 - CSS utility attributes are now deprecated in the latest version of Ionic 4, and will be going away completely in Ionic 5.

It is recommended to use class="ion-text-wrap" moving forward:

<ion-item>
    <ion-label class="ion-text-wrap">
         Multiline text that should wrap when it is too long
         to fit on one line in the item.
    </ion-label>
  </ion-item>
like image 35
NickyTheWrench Avatar answered Oct 13 '22 19:10

NickyTheWrench