Primitives
Display additional information on hover.
Import the Tooltip primitives from ng-primitives/tooltip
.
import { NgpTooltip } from 'ng-primitives/tooltip';
Assemble the tooltip directives in your template.
<button [ngpTooltipTrigger]="tooltip" ngpButton>Hover me</button>
<ng-template #tooltip>
<div ngpTooltip>Tooltip content</div>
</ng-template>
The following directives are available to import from the ng-primitives/tooltip
package:
Apply the ngpTooltip
directive to an element that represents the tooltip. This typically would be a div
inside an ng-template
.
[ngpTooltip]
ngpTooltip
Apply the ngpTooltipTrigger
directive to an element that triggers the tooltip to show.
[ngpTooltipTrigger]
ngpTooltipTrigger
Attribute | Description | Value |
---|---|---|
data-state |
The state of the tooltip. | closed | closing | open | opening |
data-disabled |
Applied when the tooltip is disabled. | - |
You can configure the default options for all tooltips in your application by using the provideNgpTooltipConfig
function in a providers array.
import { provideNgpTooltipConfig } from 'ng-primitives/tooltip';
bootstrapApplication(AppComponent, {
providers: [
provideNgpTooltipConfig({
offset: 4,
placement: 'top',
showDelay: 0,
hideDelay: 0,
flip: true,
container: document.body,
}),
],
});
Copyright © 2024 Angular Primitives