DocsFramework guides
Get started

Search Subtly documentation

Search by a task, helper name or framework.

Framework guides

Angular

Browser-only component lifecycle.

Install

Use the app root or a dedicated host component. The v3 package ships JS; strict TypeScript projects need local declarations until official types are released.

Terminal
npm install subtly

Initialize

app.component.ts

JavaScript
import { AfterViewInit, OnDestroy, Component, inject, PLATFORM_ID } from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
import { createInteractions } from 'subtly';
@Component({selector:'app-root',template:'<div data-ix="hover-intent"><button>Preview</button></div>'})
export class AppComponent implements AfterViewInit, OnDestroy {
private platform = inject(PLATFORM_ID);
private ix?: ReturnType<typeof createInteractions>;
ngAfterViewInit() {
if (isPlatformBrowser(this.platform)) { this.ix = createInteractions(); this.ix.start(); }
}
ngOnDestroy() { this.ix?.stop(); }
}

Use a behavior

HTML
<div data-ix="hover-intent" data-ix-hover-delay="150">
<button type="button">Preview</button>
</div>

Use the shared HTML attributes, or import programmatic helpers inside your framework lifecycle. State and visual rendering stay in your component.

Lifecycle and accessibility

For hydration and zoneless apps, let Angular own rendering and state. Do not use the runtime to mutate framework-controlled markup.

Use a single runtime per root; do not overlap roots. Keep native button semantics, focus and click support. For cleanup, call each utility’s returned callback or destroy method.

Try the same behavior

Preview closed. Hover, focus or click to open.

Actual npm package · local demonstrationHover timing needs a desktop pointer

The live example uses native JavaScript; the framework snippets are integration recipes, not separately compiled framework applications.