Web ComponentsNative browser standard for creating your own HTML tags, with encapsulated style and behavior, that work in any framework or none at all. have a curious reputation. Half the articles you find say they will replace frameworks; the other half say nobody uses them. Both versions have aged badly. In 2026, Photoshop on the web, GitHub and the design systems from Adobe, IBM and Microsoft use Web Components in production, and even so React is still the default for building applications.
This piece tries to take the subject out of the cheering section: what they are, what changed in browsers over the last two years, how to use them inside React and when it makes sense to go down this path.
What They Are, No Beating Around the Bush
MDN defines Web Components as a suite of technologies for creating reusable custom elements (MDN). In practice, you write a JavaScript class, register a tag name and start using that tag in HTML as if it were a <button> or a <video>.
There are three pieces, and each one solves a different problem.
Custom elements are the APIContract that defines how one program asks another for data or actions: which endpoints to call, what to send and what comes back. On the web, usually HTTP with JSON. that registers the tag and defines its lifecycle: what happens when the element enters the page (connectedCallback), leaves it (disconnectedCallback) or has an attribute changed (attributeChangedCallback). The name must have a hyphen, like meu-botao, so it never collides with a tag HTML might create in the future (WHATWG).
Shadow DOM is a DOM tree encapsulated inside the element. CSS from outside does not get in, and CSS from inside does not leak out. It is the same mechanism the browser uses for the <video> controls, which is why you cannot style the play button with a regular selector.
<template> and <slot> are the mold and the holes. The template holds a piece of HTML that is not rendered until it is cloned; the slot marks where the content the person wrote between the tags will show up.

The best analogy I know is the wall outlet. Nobody asks whether the radio is compatible with the fridge: both follow the same wall standard. A Web Component also does not need to know whether the page uses React, Vue or nothing, because its contract is the DOM itself.
What about HTML Imports? It was part of the original proposal and died along the way. Mozilla announced in 2015 that it would not implement it (Mozilla Hacks), JavaScript modules took its place, and Chrome removed the old version of the APIs in version 80, in 2020 (Chrome). Many articles still say it happened in Chrome 73, but the removal was postponed.
An Example You Can Paste and Run
A counter with a button, an attribute that sets the step and an event that notifies whoever is outside:
// contador-clique.js
const template = document.createElement('template');
template.innerHTML = `
<style>
:host { display: inline-block; }
button { font: inherit; padding: .5rem 1rem; }
</style>
<button part="botao"><slot>Click</slot>: <span id="valor">0</span></button>
`;
class ContadorClique extends HTMLElement {
static observedAttributes = ['passo'];
#valor = 0;
#passo = 1;
constructor() {
super();
const raiz = this.attachShadow({ mode: 'open' });
raiz.append(template.content.cloneNode(true));
raiz.querySelector('button').addEventListener('click', () => {
this.#valor += this.#passo;
raiz.getElementById('valor').textContent = String(this.#valor);
this.dispatchEvent(
new CustomEvent('contagem', { detail: { valor: this.#valor }, bubbles: true, composed: true }),
);
});
}
attributeChangedCallback(nome, _antigo, novo) {
if (nome === 'passo') this.#passo = Number(novo) || 1;
}
// The property mirrors the attribute. React 19 uses the property when it exists.
get passo() { return this.#passo; }
set passo(v) { this.#passo = Number(v) || 1; }
}
customElements.define('contador-clique', ContadorClique);And in the HTML:
<script type="module" src="./contador-clique.js"></script>
<contador-clique passo="2">Points</contador-clique>
<script type="module">
document.querySelector('contador-clique')
.addEventListener('contagem', (e) => console.log(e.detail.valor));
</script>Three details in this code tend to turn into bugs. The click listener lives in the constructor, not in connectedCallback, because the element can leave and come back to the page, and the listener would be duplicated. The :host { display: inline-block } is there because a custom element is born with display: inline, which surprises anyone expecting a block (web.dev, a 2017 piece, but the principles still hold). And part="botao" is the door you leave open so whoever uses the component can style the button from outside with contador-clique::part(botao).
If you want to try it without installing anything, paste both files into StackBlitz. For the Lit version, the Lit Playground is ready to go.
What Changed Between 2024 and 2026
A good share of the criticism you read was written before these changes, so it is worth dating each one.
| Feature | What it is for | Status in November 2026 |
|---|---|---|
| Declarative Shadow DOM | Building the shadow DOM in the server HTML, without JavaScript | In every browser since Firefox 123, from February 2024 |
ElementInternals |
Making the component take part in a <form> |
In all of them since March 2023 |
| Scoped custom element registries | Two versions of the same tag on the same page | In all three engines since Firefox 159, from 10/27/2026 |
| Reference Target | aria-labelledby and <label for> crossing the shadow DOM |
Without a flag only in Chromium 152 |
Customized built-ins (is="...") |
Extending a native <button> |
Safari does not plan to implement it |
Scoped registries deserve a paragraph. Until this year, there was a single tag registry per page. If two packages registered <meu-botao>, the browser threw an error and the page broke, as the Chrome blog describes (Chrome). I worked with micro-frontendsSplitting a large interface into independent parts, each with its own team, repository and deploy, combined into one page for the user. at Caixa Vida e Previdência and at Vivo, and this kind of architecture is exactly where the problem shows up: different teams, different versions of the same library, a single page. With new CustomElementRegistry(), each part of the page can have its own. Safari implemented it first, Chrome came in March and Firefox closed the loop in October (Firefox 159). The topic is one of the focus areas of Interop 2026 (WebKit).
Inside React, Finally Without Hacks
Up to React 18, using a Web Component in React required ref and addEventListener for almost everything, because React passed everything as a text attribute and did not know how to listen to custom events. React 19, released in December 2024, fixed that and passed every test in Custom Elements Everywhere (React).
The new rule is simple: if the property exists on the element instance, React assigns it as a property; otherwise, as an attribute. And a prop that starts with on becomes an event listener.
import './contador-clique.js'; // defines the tag before the first render
import { useState } from 'react';
export function Placar() {
const [total, setTotal] = useState(0);
return (
<>
<contador-clique passo={2} oncontagem={(e) => setTotal(e.detail.valor)}>
Points
</contador-clique>
<p>Total: {total}</p>
</>
);
}The import comes first on purpose. If the tag is not defined yet when React renders, the passo property does not exist and the value goes as an attribute. That works here, because the component reads the attribute, but with an object or a function the value would be lost. In TypeScript, you still need to declare the tag in the JSX types so the compiler does not complain.
On the Custom Elements Everywhere scoreboard, React, Vue, Angular, Svelte, Solid and Preact show up at 100%. Look closely, though: the site tests Angular 16, Svelte 4 and Solid 1.6, versions that are no longer current. And each framework still has its own way. Vue passes attributes by default and needs the .prop modifier to force a property; Angular always uses properties; Solid requires on: for non-standard events.
The Hard Side, Nothing Hidden

Encapsulation is the biggest strength and the biggest annoyance. Your application's global CSS does not get into the shadow DOM. To customize a component from outside, you rely on CSS variables, which cross the boundary, on ::part() and on whatever the component author decided to expose. If you are used to overriding anything with a more specific selector, it will feel strange. A proposal to make shadow DOM stylable from outside has existed since 2020 and nobody has implemented it yet.
Accessibility is the second point. Attributes that point to an id, like aria-labelledby and the for of <label>, do not cross the shadow DOM. A label on the outside cannot see the <input> on the inside. Reference Target solves this, but for now it is only available without a flag in Chromium.
The third is server rendering. The browser already understands declarative shadow DOM, but the tooling is still catching up. Lit SSR is still marked as experimental in its own documentation (Lit). Without JavaScript, a Web Component renders nothing, and that was one of the arguments of Rich Harris, creator of Svelte, in 2019: sites should work without JavaScript whenever possible, and Web Components do not (dev.to). He himself admitted there are good use cases. Two of his points, polyfills and the global namespace, have been solved since then.
In 2024 the debate came back hard. Ryan Carniato, creator of SolidJS, wrote that Web Components may be the biggest risk to the future of the web (dev.to). Cory LaViska, creator of Shoelace, replied the next day that they are not the future, they are the present, and that they do not replace a framework component one to one (dev.to). Nolan Lawson closed the week with the piece that convinces me the most: Web Components are bad at several things, like SSR, accessibility and sometimes interoperability, and replacing every framework is not their strong suit (Nolan Lawson).
When I Would Choose Web Components
For a design system that will be consumed by teams with different stacks. That is the case for Adobe with Spectrum, IBM with Carbon, Microsoft with Fluent and the bank ING with Lion. A button written once serves the React team, the Angular team and the marketing page in plain HTML. In a large company, with applications from different eras living side by side, that saves a lot of rework.
For widgets that end up on third-party sites, like a chat button or an embedded player. The shadow DOM protects the widget from the site's CSS, and the site from the widget's CSS.
For micro-frontends, now that scoped registries exist in all three engines. I explained the pros and cons of this architecture in the article on front-end system design.
For a whole application, built by a single team, I would stick with the framework. Routing, state, mature SSR, a testing ecosystem: you would have to build all of that yourself or adopt a library that ends up playing the role of a framework.
If You Are Going to Write Them, with What
A small component can be built without a library, like in the example above. Past three or four components, the repetitive attribute and rendering code starts to weigh, and then these are the options:
- Lit, from Google, at the OpenJS Foundation since October 2025. It weighs about 5 KB and is the recommended successor to Polymer, which is in maintenance mode (Lit).
- Stencil, a compiler created by Ionic, now owned by OutSystems. It generates typed components and a wrapper per framework.
- FAST, from Microsoft, which sits underneath Fluent UI Web Components.
To document and test these components in isolation, the most used tool is Storybook, and I wrote a whole article about it: Storybook with Web Components. Open Web Components brings together project generators, guides and the analyzer that generates custom-elements.json, the file that describes each component's properties and events.
Frequently Asked Questions
What are Web Components?
A set of native browser APIs for creating your own HTML tags: custom elements register the tag, shadow DOM isolates style and structure, and <template> with <slot> defines the mold and where the content goes.
Do Web Components replace React, Vue or Angular?
No. They solve the reusable component part, but they do not bring routing, state management or mature SSR. They work better alongside frameworks than in place of them.
Do Web Components work in all browsers?
Yes, since January 2020, when Edge switched to Chromium. The exception is customized built-ins, with is="...", which Safari does not plan to implement.
Can you use Web Components in React?
Yes. Since React 19, properties and custom events work directly in JSX. In earlier versions, you had to use ref and addEventListener.
Do Web Components work with SSR?
The browser has supported declarative shadow DOM in every engine since 2024, so the HTML can come ready from the server. The tooling is still maturing: Lit SSR, for example, is still experimental.
How do you style a Web Component from outside?
With CSS variables, which cross the shadow DOM, with ::part() on the elements the author marked with part, and with :host on the inside. Regular global selectors do not get in.
Does a Web Component work inside a form?
It does, if it declares static formAssociated = true and uses ElementInternals to report its value and validity. This has been in every browser since March 2023.
Do I need a library to write Web Components?
No, but it helps. For one or two components, plain JavaScript is enough. For a design system, Lit and Stencil save a lot of repetitive code.
References
- MDN. Web Components, Using custom elements and ElementInternals.
- WHATWG. HTML Standard, Custom elements.
- React. React 19 (2024).
- Chrome for Developers. Web Components update: more time to upgrade to v1 APIs and Make custom elements behave with scoped registries (2026).
- Mozilla. The state of Web Components (2015) and Firefox 159 (2026).
- WebKit. Announcing Interop 2026.
- GitHub. How we use Web Components at GitHub (2021).
- web.dev. Photoshop's journey to the web and Custom Element Best Practices (2017).
- Lit. Documentation and Lit is joining the OpenJS Foundation (2025).
- Harris, R. Why I don't use web components (2019). Carniato, R. Web Components Are Not the Future (2024). LaViska, C. Web Components Are Not the Future, They're the Present (2024). Lawson, N. Web components are okay (2024).
- Mello, R. Web Components e a minha opinião sobre o futuro das libs front-end (2024), a good opinion piece in Portuguese; just note that he wrote it before React 19.
- Farrell, B. Web Components in Action. Manning, 2019. Good for the fundamentals, predates Lit 2 and declarative shadow DOM.