Primitives

Tooltip

Display additional information on hover.

Import

Import the Tooltip primitives from ng-primitives/tooltip.

import { NgpTooltip } from 'ng-primitives/tooltip';

Usage

Assemble the tooltip directives in your template.

<button [ngpTooltipTrigger]="tooltip" ngpButton>Hover me</button>

<ng-template #tooltip>
  <div ngpTooltip>Tooltip content</div>
</ng-template>

API Reference

The following directives are available to import from the ng-primitives/tooltip package:

NgpTooltip

Apply the `ngpTooltip` directive to an element that represents the tooltip. This typically would be a `div` inside an `ng-template`.

  • Selector: [ngpTooltip]
  • Exported As: ngpTooltip

NgpTooltipTrigger

Apply the `ngpTooltipTrigger` directive to an element that triggers the tooltip to show.

  • Selector: [ngpTooltipTrigger]
  • Exported As: ngpTooltipTrigger
ngpTooltipTrigger
TemplateRef<void>
required

Access the tooltip template ref.

ngpTooltipTriggerOpen
boolean
default: "false"

The open state of the tooltip.

ngpTooltipTriggerDisabled
boolean
default: "false"

Define if the trigger should be disabled.

ngpTooltipTriggerPlacement
Placement
default: "'top'"

Define the placement of the tooltip relative to the trigger.

ngpTooltipTriggerOffset
number
default: "0"

Define the offset of the tooltip relative to the trigger.

ngpTooltipTriggerShowDelay
number
default: "0"

Define the delay before the tooltip is displayed.

ngpTooltipTriggerHideDelay
number
default: "0"

Define the delay before the tooltip is hidden.

ngpTooltipTriggerFlip
boolean
default: "true"

Define whether the tooltip should flip when there is not enough space for the tooltip.

ngpTooltipTriggerContainer
HTMLElement | null
default: "document.body"

Define the container in which the tooltip should be attached.

ngpTooltipTriggerOpenChange
boolean

Emit an event when the tooltip is opened or closed.

Data Attributes

Attribute Description
data-open Applied when the popover is open.
data-disabled Applied when the tooltip is disabled.

Animations

The ngpTooltip primitive adds a CSS custom property --ngp-tooltip-transform-origin to the element that can be used to animate the tooltip from the trigger element.

Global Configuration

You can configure the default options for all tooltips in your application by using the provideTooltipConfig function in a providers array.

import { provideTooltipConfig } from 'ng-primitives/tooltip';

bootstrapApplication(AppComponent, {
  providers: [
    provideTooltipConfig({
      offset: 4,
      placement: 'top',
      showDelay: 0,
      hideDelay: 0,
      flip: true,
      container: document.body,
    }),
  ],
});

NgpTooltipConfig

offset
number

Define the offset from the trigger element.

placement
'top' | 'right' | 'bottom' | 'left'

Define the placement of the tooltip.

showDelay
number

Define the delay before the tooltip shows.

hideDelay
number

Define the delay before the tooltip hides.

flip
boolean

Define if the tooltip should flip when it reaches the edge of the viewport.

container
HTMLElement

Define the container element for the tooltip. This is the document body by default.

Copyright © 2025 Angular Primitives