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

164
Visualizações
How to avoid repetition of CSS properties across multiple Web Components

I'm building with Web Component without any 3rd-party framework.

And I have vanilla <button> in several of my components, and I have to reset EVERY ONE of them before I do my custom styling on them because resetting it once at a root level doesn't work since the properties involved are not one of inheritable styles that pierce through shadow dom:

button {
   appearance: none;
   background: none;
   border: none;
   ...
}

What do you all think is the current best and widely supported way to avoid this repetition?

I have looked at the Constructable Stylesheets, but it's poorly supported in Firefox, which is my main browser. I also considered CSS Custom Properties, but that would still lead to repetition of background, border etc. properties everywhere right?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Constructable stylesheets are designed to address, among others, exactly this problem you're having.

There has been experimental support for constructable stylesheets in Firefox since version 73 (Feb. 2020). Not sure why it hasn't left the experimental feature status for more than 2 years now.

You can enable it by setting layout.css.constructable-stylesheets.enabled to true in about:config.

Until it's no longer experimental, you can use a polyfill.

The next thing that will help you reduce redundancy is called CSS Module Scripts. From that page:

Deduplication: if the same CSS file is imported from multiple places in an application, it will still only be fetched, instantiated, and parsed a single time.

Unfortunately, that also hasn't landed in Firefox yet (see this tracking bug), but already in the specification.

about 4 years ago · Juan Pablo Isaza Relatório

0

But if i say to tailwind css with reactjs. Reactjs specially designed to remove repetition. Please check tailwind docs where even you can assign your custom css function for anything.

about 4 years ago · Juan Pablo Isaza 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