Search code examples
cssionic-frameworkionic3floating-action-button

Ionic 3 How to add a non-wrapping label to a fab


I have a fab list with fab buttons that shall have labels.

I found Fabs With Labels In Ionic 3 & whats the correct way of inserting label in an Ionic FAB list.

My HTML code is:

<ion-fab left top>
    <button ion-fab color="light">
      <ion-icon name="menu"></ion-icon>
    </button>

    <ion-fab-list side="bottom">

      <button ion-fab>
        <ion-icon name="person"></ion-icon>
        <ion-label>Test Test Test</ion-label>
      </button>


      <button ion-fab>
        <ion-icon name="alarm"></ion-icon>
        <ion-label>Bla Bla</ion-label>
      </button>

    </ion-fab-list>

  </ion-fab>

CSS

button[ion-fab] {
  overflow: visible;
  position: relative;

  ion-label {
    display: inline-block;
    position: absolute;

    top: -8px;
    left: 60px;

    color: white;
    background-color: rgba(0,0,0,0.7);
    line-height: 24px;
    padding: 4px 8px;
    border-radius: 4px;


    pointer-events: auto;
  }

  contain: layout;
}

But the labels break the text to a newline if i don't specify a width. If i do the labels don't adjust their width to the label's content.

enter image description here

How do i make the label content not wrap to a new line?


Solution

  • Issue originated from

    ion-label {
      white-space: normal !important;
    }
    

    from my app.scss