# Attribute Directive

A directive that changes the look or behavior of an existing element.

## What is **Attribute Directive**?

An **attribute directive** changes the look or behavior of an existing element. You write your own with `@Directive` and use it like an attribute.

```typescript
@Directive({ selector: '[appHighlight]', host: { '(mouseenter)': 'on()', '(mouseleave)': 'off()' } })
export class Highlight {
  private el = inject(ElementRef);
  on() { this.el.nativeElement.style.background = 'yellow'; }
  off() { this.el.nativeElement.style.background = ''; }
}
```

Level: Journeyman · [More Angular terms at this level](https://www.ask-codey.com/glossary?category=angular&level=3)

Updated: September 27, 2026

Source: https://www.ask-codey.com/glossary/attribute-directive
