IT lexicon › Web › Web components

Web components

Web På svenska → Updated: 2026-07-30

A set of web standards for building reusable, encapsulated, framework-agnostic HTML elements. The umbrella term covers three parts: Custom Elements (your own tags), Shadow DOM (encapsulation), and HTML Templates. A standards-based alternative to framework components.

The three pillars: Custom Elements — define your own elements (<my-card>) with their own JS logic and lifecycle; Shadow DOM — give the element an encapsulated, isolated DOM and style tree so its CSS doesn't leak out and the page's CSS doesn't leak in; HTML Templates (<template>) — inert markup cloned as needed. Win: components that work in any framework (or with none), with true encapsulation, built on web standards that don't go obsolete. Use case: design systems shared across teams/frameworks (Shoelace, Adobe Spectrum), embeddable widgets. Trade-off: more verbose than a framework for building apps, and the ecosystem is smaller. Libraries like Lit make them nicer to write. The standards-based component model. Related to custom elements (Shadow DOM) and slot-element.

← Back to the lexicon