Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

261
Views
How to add SCSS to a component of an angular library

I've created a library in angular 6. The problem is that styling is not applied. Here is my code:

mycustom.component.html

<div class="cutom-div">
    Hello
</div>

mycustom.component.ts

import { Component, OnInit } from "@angular/core";

@Component({
  selector: "lib-mycustom",
  templateUrl: "./mycustom.component.html",
  styleUrls: ["./mycustom.component.scss"],
})
export class MycustomComponent implements OnInit {
  constructor() {}

  ngOnInit() {}
}

mycustom.component.scss

.custom-div {
    background: red;
    height: 20px;
}

This was supposed to be simple. But there's no styling applied. I inspected the element also:

enter image description here

enter image description here

What else I'm missing out here. Please point out my mistake.

I'm building the library normally:

ng build my-library and then cd dist\my-library>npm pack

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

https://angular.io/api/core/ViewEncapsulation#None

None means that Angular does no view encapsulation. Angular adds the CSS to the global styles. The scoping rules, isolations, and protections discussed earlier don't apply. This mode is essentially the same as pasting the component's styles into the HTML.

@Component({
  selector: "lib-mycustom",
  templateUrl: "./mycustom.component.html",
  styleUrls: ["./mycustom.component.scss"],
  encapsulation: ViewEncapsulation.None, // <- This need use for global style
})

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!