The Tooltip component provides a flexible way to display additional information, hints, or interactive content. It supports hover and copy actions within the content popover, configurable delay options, automatic positioning, focus trapping for accessibility, click outside interaction, keyboard operations, and dark mode support.
Examples
Example 1: Basic Tooltip
In this usage, you can simply add a tooltip by specifying the content directly or through attribute directive cllTooltipContent. Additional configurations such as hide delay and width can be customized as per your requirements.
import {TooltipModule} from'clr-lift';
import {Component} from'@angular/core';
@Component({
imports: [TooltipModule],
template: `
<a href="javascript:void(0)" cllTooltip="This is our cllTooltip text">Basic Tooltip 1</a>
<a
href="javascript:void(0)"
cllTooltip
cllTooltipContent="This is our cllTooltip text"
[cllTooltipHideDelay]="500"
[cllTooltipWidth]="100"
>
Basic Tooltip 2
</a>
<a href="javascript:void(0)" cllTooltip cllTooltipContent="">Empty Content Will NOT Show Tooltip</a>
`
})
exportclassBasicTooltipExampleComponent {}
Tooltip accepts dynamic content provided through Angular templates. You can specify templates using ng-template and bind them to the tooltip component for dynamic display. This allows for more interactive and customized tooltips.
import {TooltipModule} from'clr-lift';
import {Component} from'@angular/core';
@Component({
imports: [TooltipModule],
template: `
<a
href="javascript:void(0)"
cllTooltip
[cllTooltipContent]="content"
[cllTooltipContentContext]="{$implicit: 'TemplateRef Example', value: '❤️'}"
[cllTooltipWidth]="350"
[cllTooltipPosition]="'tooltip-top-right'"
>
TemplateRef Example
</a>
<ng-template #content let-data let-value="value">
{{ 'A great tooltip:' }} {{ data }} {{ value }}
<cll-callout> You can also put a component inside ng-template </cll-callout>
</ng-template>
`
})
exportclassTemplateRefTooltipExampleComponent {}
cllTooltipContentContext is optional, it's the context that will be passed to the ng-template during creating the embedded view.
Example 3: Tooltip with Component Reference
Tooltip can display content from Angular components dynamically. It demonstrates how you can create and inject components into the tooltip, providing endless possibilities for displaying rich and interactive content.