Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

256
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda