Web components

Hand-drawn seven identical rounded terracotta squares filled with sand and umber cross-hatching, scattered across flowing cream, sand, umber and moss contour lines.

Web components are browser standards for defining reusable HTML elements and giving them their own markup and styles. Different frameworks can supply values through the same element’s interface (WHATWG, n.d.e; WHATWG, n.d.a; Atkins & Daly, 2026; The React Team, 2024; Vue.js, n.d.b). Tests show interoperability for specific framework versions, and speed comparisons vary with the implementation and task (Custom Elements Everywhere, n.d.; Norrman, 2020; Ronde, 2021).

Custom elements, shadow DOM, and templates

An author defines a custom element’s behavior in JavaScript, including how the browser creates it. The browser can run a connection callback, a function invoked when the element joins the document, more than once. The author can also list which HTML attributes trigger an attribute-change callback (WHATWG, n.d.e).

Shadow DOM lets an element keep an internal tree of nodes. The element is the host, and the shadow root attaches the internal tree to it (WHATWG, n.d.a). CSS selectors, which pick the elements a style rule applies to, generally operate within one tree. Style inheritance still uses a combined tree that includes the shadow content (Atkins & Daly, 2026).

An ordinary <template> holds an HTML fragment for reuse. It has no visible output of its own. A script can copy the fragment and insert it into the document (WHATWG, n.d.f).

From v0 to declarative shadow DOM

Early Chrome versions registered custom elements with document.registerElement(), the v0 API. The v1 API uses customElements.define(). Custom elements v1 was available in Chrome 54, Safari 10.1, and Firefox 63 (Bidelman, 2017). Chrome 80 removed custom elements v0 alongside shadow DOM v0 and HTML Imports (Google, 2019a).

Declarative shadow DOM extends server rendering to a component’s internal tree. When the browser parses a template with the shadowrootmode attribute, it attaches the template content as the parent element’s shadow tree. The browser can build that tree directly from the HTML response, without JavaScript (Miller & Freed, 2024).

A slot is a place inside the shadow tree where content from outside that tree can appear. Declarative shadow DOM supports that placement in static HTML and reached all three major browser engines by August 2024 (Miller & Freed, 2024).

Framework interoperability

Frameworks can pass values to custom elements through properties on the JavaScript object or attributes on the HTML tag. In the browser, React 19 sets a property when the element exposes one with the matching name and otherwise sets an attribute (The React Team, 2024). Vue 3 also prefers a matching property. Vue’s defineCustomElement() method lets authors package Vue components as custom elements (Vue.js, n.d.b).

Custom Elements Everywhere reported that its entries for React ^19 and Vue ^3.2.38 each passed all 16 basic and all 16 advanced tests. The suite describes its cases as a proposed set of interoperability expectations (Custom Elements Everywhere, n.d.).

Forms and accessible labels

Custom elements can take part in HTML forms. An element associated with a form can tell the browser what value to submit using ElementInternals, an interface to browser features. It can also report which validity rules the input violates and supply a message (WHATWG, n.d.e).

Shadow DOM affects which nodes an accessibility label can refer to. For example, aria-labelledby supplies the ID of another element whose content labels the control. Such ARIA attributes, which describe elements for assistive technology, can name IDs only within the same tree. The corresponding JavaScript properties can refer directly to elements in a tree that contains the shadow tree (Chrome for Developers, 2026).

Chrome 152’s release notes describe an origin trial, a limited browser experiment, for a feature called Reference Target. When an ID reference points to the host, the trial feature forwards it to a designated element inside the shadow tree (Chrome Platform Status, n.d.).

A 2024 test used the VoiceOver screen reader to read a label supplied by an element with shadow content and display: contents. VoiceOver skipped that text in Safari 17.5 and read it in Firefox 126.0.1 and Chrome 125.0.6 (Rogers, 2024). WebKit lists a fix for this case in its Safari 27.0 release notes (Simmons et al., 2026).

Adoption and deployments

The 2024 Web Almanac’s JavaScript chapter found custom elements on 7.8% of desktop pages in its crawl. It reported shadow DOM on 2.51% of mobile pages in 2024 and 0.39% in 2022 (Amjad & Goel, 2025).

The Almanac’s Markup chapter reported custom elements on 3.6% of what it calls mobile sites in 2022 and 7.9% in 2024. The 2024 dataset added secondary pages alongside home pages (Franco, 2024). The figures represent comparable rates only if both years used the same page-selection rule.

Chromium’s use counter measures the daily share of browser page visits that use a feature. In 2018, roughly 5% of Chrome page views used v0 custom-element registration, including desktop YouTube visits (Chromium, n.d.c; Ito, 2018).

Named deployments include GitHub, which reported more than a dozen open-source web components in 2021 alongside dozens of closed-source ones (Oddsson, 2021). Adobe implements its Spectrum design system as web components using LitElement. Salesforce provides versions of its Lightning base components as Lightning web components and as Aura components (Adobe, n.d.b; Salesforce, n.d.).

Performance and maintainability Weak evidence: few or small studies support this

The performance evidence is limited to specific implementations and tasks. A 2020 benchmark timed operations on table rows. The Kirei web-component implementation updated them faster than the Vue implementation, and Vue created them faster (Norrman, 2020). The benchmark archive advises comparing results within a release because browser versions, processor throttling, and measurement methods change (Krause et al., n.d.).

A 2021 case study at the software company 30MHz compared its original Angular-based components with their web-component versions. The migrated JavaScript took roughly twice as long to load. A single migrated component took about 5 milliseconds longer to render (Ronde, 2021). The same case study found indications of little change in how easy the original codebase was to maintain (Ronde, 2021).

Further reading

  • HTML standard on custom elements covers element definitions, lifecycle callbacks, and participation in forms (WHATWG, n.d.e).
  • Declarative shadow DOM explains how a browser builds a shadow tree from an HTML response (Miller & Freed, 2024).
  • Accessible web components explains where accessibility references can resolve across element trees (Chrome for Developers, 2026).
  • Custom Elements Everywhere lists basic and advanced interoperability results by framework (Custom Elements Everywhere, n.d.).

Known gaps

What this article cannot tell you yet.

  1. It is unclear whether the Web Almanac’s 2022 and 2024 mobile custom-element figures use the same page-selection rule.
  2. No long-term comparison of web components and framework components is covered. The maintainability evidence here comes from one migration.
  3. The article gives no current estimate of the share of page visits that use custom elements.

References

Solid source
Rated highly trustworthy by the research, and every passage taken from it was found in it.
Weak source
Rated low, or a passage taken from it was not found in it.
Medium trust
Rated medium by the research.
Not checked
Rated high, but its passages could not all be checked against it.
Show all 24 references