All posts

Understanding Web Components in 2026

Web Components have matured significantly. Here's a practical look at where they shine and where you're still better off with a framework.

S
Sam Rivera
·

Web Components have been “the future” for over a decade. In 2026, they’re finally just… the present. Browser support is universal, the APIs have stabilized, and real projects are shipping with them. But they’re not a silver bullet. Let’s look at where they actually make sense.

The basics in 60 seconds

A Web Component is a custom HTML element with encapsulated markup, styles, and behavior. You define one with a class:

class UserCard extends HTMLElement {
  connectedCallback() {
    const name = this.getAttribute('name');
    this.innerHTML = `
      <div class="card">
        <h3>${name}</h3>
        <slot></slot>
      </div>
    `;
  }
}

customElements.define('user-card', UserCard);

Now you can use <user-card name="Alex">Senior Engineer</user-card> anywhere in your HTML. No build step required.

Shadow DOM: the double-edged sword

Shadow DOM gives you style encapsulation. Styles inside the shadow root don’t leak out, and outside styles don’t leak in. This sounds great until you want your design system’s typography to apply inside a component.

The solution is CSS custom properties, which do pierce the shadow boundary:

/* Outside the component */
:root {
  --card-bg: #f8fafc;
  --card-radius: 8px;
}

/* Inside the component's shadow DOM */
:host {
  background: var(--card-bg);
  border-radius: var(--card-radius);
}

This is the right mental model: the component owns its internal layout, but defers to the host page for theming.

Where Web Components shine

Design systems and shared UI. If your organization has multiple apps built with different frameworks, Web Components are the one thing that works everywhere. A <company-button> element can be used in React, Vue, Svelte, or plain HTML without wrappers.

Third-party embeds. If you’re building a widget that other people embed on their sites (like a chat widget or a pricing calculator), Web Components with Shadow DOM give you isolation from the host page’s styles.

Progressive enhancement. You can ship a basic HTML experience and enhance it with a Web Component. If the JS fails to load, the content is still there.

Where frameworks still win

Complex state management. Web Components have no built-in reactivity. You’re managing state with properties, attributes, and manual DOM updates. Libraries like Lit smooth this over, but it’s still more ceremony than useState or Svelte’s $state.

Server-side rendering. Declarative Shadow DOM exists, but framework-level SSR with hydration is still more mature and better supported by hosting platforms.

Developer experience. Hot module replacement, devtools integration, and rich error messages — frameworks have had years to polish the DX. Vanilla Web Components feel spartan by comparison.

The pragmatic approach

Use Web Components when you need portability or isolation. Use a framework when you need productivity on a single application. And don’t be afraid to mix them — most modern frameworks can consume Web Components seamlessly.

The best part? Everything you learn about Web Components is just the web platform. No framework churn, no migration guides. That knowledge compounds forever.