Back to Skills

angular-directives

Create custom directives in Angular v20+ for DOM manipulation and behavior extension. Use for attribute directives that modify element behavior/appearance, structural directives for portals/overlays, and host directives for composition. Triggers on creating reusable DOM behaviors, extending element functionality, or composing behaviors across components. Note - use native @if/@for/@switch for control flow, not custom structural directives.

589stars68forksUpdated 5/5/2026

Security Assessment

Safe(100/100)
Security Score100/100

About angular-directives

The `angular-directives` skill enables developers to create custom directives in Angular v20+ to enhance DOM manipulation and extend element behavior. This skill addresses the common need for reusable, composable behaviors in Angular applications, allowing developers to encapsulate functionality in directives rather than repeatedly writing similar code across components. By leveraging attribute directives, structural directives, and host directives, developers can modify element appearance, handle events, and compose behaviors in a maintainable and scalable way. The skill emphasizes modern Angular practices, including using native @if/@for/@switch for control flow instead of custom structural directives, ensuring compatibility with Angular's latest standards.

Key features of this skill include creating attribute directives to modify element behavior or styling, utilizing the host property for binding events and attributes, and managing class and style dynamically. It also supports event handling for both DOM and custom events, and enables keyboard shortcut handling through directive-based configuration. The skill provides examples of reusable directives like highlighting text, tooltips, button styling, click outside detection, and shortcut key handling. It leverages Angular's reactive patterns with input/output decorators and effects to maintain efficient and responsive behavior.

This skill is ideal for Angular developers aiming to improve code reusability, reduce boilerplate, and create modular UI components. It is particularly useful for teams building complex web applications where consistent DOM behavior and UI interactions are needed across multiple components. Target users include frontend developers working with Angular v20+ who want to implement custom, reusable directives for behavior composition, styling, event handling, and accessibility improvements.

FAQ

Which Angular versions are compatible with angular-directives?

This skill is designed for Angular v20 and later versions. Earlier versions may not support the APIs used, such as the new reactive input/output patterns and effects.

Can I use custom structural directives for control flow?

No, the skill recommends using native @if, @for, and @switch for control flow instead of creating custom structural directives.

How do I bind events and attributes to an element?

Use the host property in the directive metadata to bind DOM events and element attributes, which is preferred over @HostBinding and @HostListener decorators.

Can I dynamically change classes and styles with this skill?

Yes, you can manipulate classes and styles dynamically using the host property with conditional expressions based on directive inputs.

Are these directives reusable across multiple components?

Yes, directives created with this skill are designed to be reusable and composable, allowing consistent behavior and styling across different components in your Angular application.

All Files

2 files
SKILL.md10.6 KB
View
references/directive-patterns.md12.5 KB
View

Install angular-directives

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill