What problem does it solve?
Building reusable DOM behaviors in Angular often leads to duplicated code, inconsistent lifecycle handling, and fragile event/host interactions; developers need clear, composable directive patterns to encapsulate functionality like tooltips, lazy rendering, portals, and accessibility features.
Core Features & Use Cases
- Attribute Directives: Encapsulate style, class, and behavior changes (highlighting, tooltips, keyboard shortcuts, click-outside).
- Structural Directives: Provide safe insertion points, portals, lazy render, and template outlets for overlays and dynamic content.
- Host Directives & Composition: Compose reusable behaviors across components using host directives, inputs/outputs wiring, and exported directive references.
- Platform Integrations: Patterns for IntersectionObserver, ResizeObserver, drag-and-drop, infinite scroll, lazy image loading, form masking, and permission-based rendering.
- Use Case: Replace repeated UI logic with typed, testable directives that manage DOM, cleanup, accessibility attributes, and inter-directive composition in Angular v20+ applications.
Quick Start
Create an Angular attribute directive named appHighlight that accepts a color input and applies a background color to the host element.