Skip to content
masterclass Buddy

Angular · Directive

ngStyle

NgStyle updates styles on its containing HTML element. Bind it to style key-value pairs, with optional unit suffixes such as .px; a null value removes that style.

Last updated

Syntax

class NgStyle implements DoCheck {
  constructor(_ngEl: ElementRef<any>, _differs: KeyValueDiffers, _renderer: Renderer2);
  @Input() set ngStyle(value: { [klass: string]: any } | null | undefined);
}

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • CommonModule
  • NgClass
  • Renderer2
  • KeyValueDiffers
  • ElementRef

Source: NgStyle • Angular. Checked 2026-11-03.