# Title

- Entry point: `@koobiq/components/title`
- NgModule: `KbqTitleModule`
- API: https://koobiq.io/api/title.md
- Page: https://koobiq.io/en/components/title/overview

The `kbq-title` directive shows a [tooltip](https://koobiq.io/en/components/tooltip.md) 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.

[**Example: Title** (`title-overview`)](https://koobiq.io/examples/title-overview.md)

## Key features

- 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.

## Container and text

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.

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

## Multiple text elements

When the container holds several text elements (for example, a name and a value in a [filter-bar](https://koobiq.io/en/components/filter-bar.md) pipe), mark each of them with `#kbqTitleText`. The tooltip appears if at least one element overflows.

[**Example: Multiple text elements** (`title-multiple-text`)](https://koobiq.io/examples/title-multiple-text.md)

## Multiline text

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

[**Example: Multiline text** (`title-vertical-overflow`)](https://koobiq.io/examples/title-vertical-overflow.md)

## Custom tooltip 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.

[**Example: Custom tooltip content** (`title-custom-content`)](https://koobiq.io/examples/title-custom-content.md)

## Two-line list options

In two-line [list](https://koobiq.io/en/components/list.md) 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.

[**Example: Two-line list options** (`title-list-option`)](https://koobiq.io/examples/title-list-option.md)

## Triggers

The tooltip always opens on hover and on keyboard focus. `kbqTrigger` is a single input alias shared with
[Tooltip](https://koobiq.io/en/components/tooltip.md) and [Popover](https://koobiq.io/en/components/popover.md), 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.

## Recommendations

- 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](https://koobiq.io/en/components/tooltip.md) or [Popover](https://koobiq.io/en/components/popover.md).
- Keep the tooltip content short and clear.
