DEV Community

Alaa Courdova
Alaa Courdova

Posted on

Using Styles and StyleUrls Component Properties in Angular

Problem
repeating a style is common while coding , for example: - container , font-style buttons ..etc.

As angular component is separated (CSS and HTML) , We face a repetitive code and if we need to change a style we needs to change many time for minor change -maybe-

โœจSolution

styleUrls: ['./component1.scss',
'../component2.scss']

@Component({
  selector: 'component',
  templateUrl: './component.html',

  styleUrls: ['./component1.scss',
    '../component2.scss']
})

export class Component implements OnInit {
  ngOnInit(): void {
  }
}

Enter fullscreen mode Exit fullscreen mode

so if the style we need is existing in a different component we can add the path of CSS , better than copying the style code

Top comments (2)

Collapse
 
naucode profile image
Al - Naucode

Hey, that was a nice read, you got my follow, keep writing ๐Ÿ˜‰

Collapse
 
alaa_courdova profile image
Alaa Courdova

I appreciate it , thank you