Interactions

Hover

Normalizes the hover event across different browsers and devices.

Not Hovering

Import

Import the Hover primitive from ng-primitives/interactions.

import { NgpHover } from 'ng-primitives/interactions';

Usage

Assemble the hover directives in your template.

<div
  (ngpHover)="onHoverChange($event)"
  (ngpHoverStart)="onHoverStart()"
  (ngpHoverEnd)="onHoverEnd()"
></div>

API Reference

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

NgpHover

Apply the `ngpHover` directive to an element that you want to listen for hover events. T his is particulaly useful for supporting hover events on touch devices, where hover events are not handled consistently. On iOS relying on the `:hover` pseudo-class can result in the hover state being stuck until the user taps elsewhere on the screen.

  • Selector: [ngpHover]
  • Exported As: ngpHover
ngpHoverDisabled
boolean

Whether hoving should be disabled.

ngpHoverStart
void

Emit an event when hovering starts.

ngpHoverEnd
void

Emit an event when hovering ends.

ngpHover
boolean

Emit an event when the hover state changes.

Data Attributes

Attribute Description
data-hover Added to the element when hovering occurs.

Copyright © 2025 Angular Primitives