The kbq-title directive shows a tooltip with the full text when the element's content does not fit and is truncated with an ellipsis. The tooltip appears only on actual overflow — on hover or keyboard focus — and stays out of the way when the text is fully visible.

Just a text and a long text and a long text and a long text and a long text and a long text and a long text
  • The tooltip appears only when the text overflows — horizontally or vertically (when clamped to a number of lines). If the text fits, no tooltip is shown.
  • Works both with plain text and with complex nested markup via the #kbqTitleContainer (measured container) and #kbqTitleText (text element) template references.
  • Supports multiple #kbqTitleText elements: the tooltip is shown if any of them overflows.
  • Lets you provide custom tooltip content — a string or a template — through the [kbq-title] attribute.
  • While the pointer or the keyboard focus is on the element, tracks content changes and container resizes — including those that do not resize the window, such as dragging a splitter or collapsing a sidebar — and shows or hides the tooltip as the text starts or stops fitting.
  • Accessibility: the tooltip opens on keyboard focus and hides when focus is lost.

To detect overflow correctly in nested markup, mark the measured container with #kbqTitleContainer and the text element with #kbqTitleText. The directive compares the container and text sizes and shows the tooltip when the text does not fit.

<div kbq-title>
    <div #kbqTitleContainer>
        <div #kbqTitleText>{{ value }}</div>
    </div>
</div>

When the container holds several text elements (for example, a name and a value in a filter-bar pipe), mark each of them with #kbqTitleText. The tooltip appears if at least one element overflows.

Status:A long value that does not fit and is truncated with an ellipsis

The directive accounts for vertical overflow as well as horizontal. This is useful when the text is clamped to several lines (-webkit-line-clamp).

A long multiline text clamped to two lines. When it does not fit into the allotted lines, the title directive shows a tooltip with the full content.

By default the truncated text of the element is used as the tooltip content. To provide custom content, pass a string or a template reference (TemplateRef) to the [kbq-title] attribute. This is handy when you need formatted text or extra information.

Plain string content
A long text that does not fit into the container and is truncated with an ellipsis
Rich template content
A long text that does not fit into the container and is truncated with an ellipsis

In two-line list options a single kbq-title directive can cover the whole option. Mark both lines (name and description) with #kbqTitleText and the shared container with #kbqTitleContainer. The tooltip appears when at least one of the lines overflows and shows the full text of the option.

serverName serverName serverName serverName serverName serverName serverName serverName
description serverName serverName serverName serverName serverName
shortName
short description
anotherServer anotherServer anotherServer anotherServer anotherServer anotherServer
description anotherServer anotherServer anotherServer anotherServer

The tooltip always opens on hover and on keyboard focus. kbqTrigger is a single input alias shared with Tooltip and Popover, so an element carrying both kbq-title and kbqPopover passes one value to both directives — kbq-title accepts it and keeps its own behavior. Use kbqTooltip or kbqPopover when you need a custom trigger.

  • Use kbq-title for text that can be truncated: headings, table cells, values in filters and lists.
  • If the tooltip must always be shown (not only on overflow) or contain interactive elements, use Tooltip or Popover.
  • Keep the tooltip content short and clear.
Suggestions for improvement
If you found a mistake or want to improve the article, create an issue on GitHub.