Migrating Popups from Semantic UI

In this document we'll be using SUI for ng2-semantic-ui and Bootstrap for ng-bootstrap. We'll also be using <span> elements in the examples, but any element can be associated with a tooltip.

See the SUI popup specs for more info.

Migrating simple popups

"Simple" SUI popups show fixed text. They follow this structure:

<span suiPopup popupText="..."> ... </span>

The UI Guidelines provide a CSS-only partial re-implementation of those popups. For more complex use cases (e.g., dynamically generated tooltip text; using a template for the tooltip body), see below.

<span tooltip-text="..."> ... </span>

Attributes tooltip-position and tooltip-size can also be used to customize the popup.

Notes

  <button class="btn btn-primary" (click)="..."
        tooltip-text="First line.
                      Second line.
                      Third and last line."
   ...
  </button>

Migrating dynamic popups

"Dynamic" SUI popups show text that's computed at runtime and accessed via Angular interpolation. They follow this structure:

<span suiPopup popupText="{{ ... }}"> ... </span>

The equivalent Boostrap component is based on ngbPopover. (See the specs for more info.)

<span ngbPopover="{{ ... }}"
      triggers="mouseenter:mouseleave"
      container="body">
    ... 
</span>

Notes

Migrating template-based popups

SUI template-based popups follow this structure:

<ng-template let-popup #popupTemplate>
    ...
</ng-template>

<span suiPopup [popupTemplate]="popupTemplate"> ... </span>

Notes

  <button (click)="popup.close()"> Close </button>

The equivalent Boostrap component is also based on ngbPopover. (See the template-specific specs for more info.)

<ng-template #popupTemplate>
    ...
</ng-template>

<span [ngbPopover]="popupTemplate"
      triggers="mouseenter:mouseleave"
      container="body">
    ... 
</span>

Notes

ngbTooltip

Bootstrap tooltips can be implemented as ngbTooltip-based components as well. They have a very similar structure to SUI popups but are rather inflexible. A solution based on ngbPopover allows better styling and finer control, and it should be preferred over ngbTooltip, even though the syntax is more verbose.

However, ngbTooltip-based tooltips may be of value in a migration as well. A template-based example would be:

<ng-template #popupTemplate>
    ...
</ng-template>

<span [ngbTooltip]="popupTemplate"> ... </span>

Notes

  <div>
    <td [ngbTooltip]="popupTemplate"> ... </td>
  </div>