Skip to main content
cngx-src documentation

CngxHoverable

DirectivePrimaryv0.1.0

projects/common/interactive/hoverable/hoverable.directive.ts

Import#

import { CngxHoverable } from '@cngx/common/interactive'

Description#

Tracks whether the host element is currently hovered via mouse pointer.

Designed as a hostDirective composition primitive - attach it to components that need hover state without implementing their own mouseenter/mouseleave logic. The hovered signal is writable so host components can read it via inject(CngxHoverable, { host: true }).

Used internally by CngxTreetableRow for row highlight-on-hover.

As hostDirective

@Component({
  hostDirectives: [{ directive: CngxHoverable }],
})
export class MyCard {
  private readonly hover = inject(CngxHoverable, { host: true });
  readonly isHovered = this.hover.hovered; // Signal<boolean>
}

Standalone

<div cngxHoverable #h="cngxHoverable" [class.highlight]="h.hovered()">
  Hover me
</div>

Metadata#

Host#

Index#

Properties

Instance Properties#

hovered#unknown
signal()Readonly

true while the pointer is over the host element.

signal(false)

HostListeners#

EventHandler
(mouseenter)mouseenter()
(mouseleave)mouseleave()