Skip to content
Related Articles

Related Articles

Improve Article

What is NgStyle in Angular 10 ?

  • Last Updated : 30 Apr, 2021

In this article, we are going to see what is NgStyle in Angular 10 and how to use it.

NgStyle is used to add some style to an HTML element


<element [ngStyle] = "typescript_property">


  • Create the Angular app to be used
  • In app.component.html make an element and sets its class using ngStyle directive
  • Serve the angular app using ng serve to see the output

Example 1:


import { Component, OnInit } from '@angular/core';
    selector: 'app-root',
    templateUrl: './app.component.html'
export class AppComponent {


<div [ngStyle] ="{'background-color':'green'}">
<div [ngStyle] ="{'color':'GREEN'}">


My Personal Notes arrow_drop_up
Recommended Articles
Page :