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

162
Views
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 answers
Answer question

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 Report

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 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!