Home Insights Web components: The browser's building blocks, and why the UAE Design System is built on them

Web components: The browser's building blocks, and why the UAE Design System is built on them

Technology 14 min read

Open the source of almost any government service built in the last decade and you will find the same button built five different ways. One team wrote it in React. Another in Angular. A third used a content management system theme. A vendor added a fourth inside a payment widget. Each one looks almost the same, behaves slightly differently, and has to be tested, fixed and made accessible on its own.

The web has had a native answer to this problem for some time. It is called web components, and it took the platform more than twenty years to get right. Today it is the foundation of the UAE Design System, which ships every one of its components as a standards-based web component.

This article explains what web components are, where they came from, who already depends on them, and why they matter for teams building digital services for the UAE federal government. Along the way, you can try three live demos built with the same components.


What are web components?

Web components are a set of browser standards that let you define your own HTML elements, with their own markup, styles and behaviour, and use them anywhere HTML works. Once a component is defined, the browser treats it like any built-in element. You write <aegov-button> in exactly the same way you would write <button>.

Three standards do most of the work:

Standard What it does Everyday analogy
Custom Elements Registers a new tag name, such as aegov-input, and the JavaScript class that powers it. The browser handles its life cycle: created, connected to the page, attributes changed, removed. Adding a new word to the browser's vocabulary.
Shadow DOM Gives an element a private, encapsulated DOM tree and style scope. Page CSS cannot accidentally reach in, and the component's CSS cannot leak out. A sealed room with a window: you can see in, but you cannot rearrange the furniture.
HTML templates and slots <template> holds inert markup ready to be cloned. <slot> marks where the content you write between the tags should appear. A form with labelled blanks for you to fill in.

They are supported by the platform itself, so there is no framework runtime involved in making a custom element work. Modern JavaScript modules, which replaced an early "HTML Imports" proposal, handle the loading.

At its simplest, a custom element is a class and a single line of registration:

class ServiceStatus extends HTMLElement {
  connectedCallback() {
    const state = this.getAttribute('state') ?? 'unknown';
    this.textContent = `Service status: ${state}`;
  }
}

customElements.define('service-status', ServiceStatus);
<service-status state="online"></service-status>

Every custom element name must contain a hyphen. That small rule guarantees a custom tag will never clash with a future built-in HTML element, which is why every component in the UAE Design System carries the aegov- prefix.


A short history: Twenty-five years in the making

The idea of extending HTML with your own elements is almost as old as the web browser itself. What took time was agreement. Each early attempt was tied to a single browser, and each one taught the industry something about what a shared standard needed to be.

Microsoft's HTML Components in Internet Explorer let developers attach script "behaviours" to elements in the late 1990s. Netscape and Mozilla's XBL (XML Binding Language) followed in 2001 and was used to build much of Firefox's own interface. Neither became a cross-browser standard. The modern term arrived in 2011, when Google's Alex Russell introduced "Web Components" at the Fronteers conference in Amsterdam. After a first version that only Chrome shipped, browser vendors agreed on a reworked "v1" design in 2016, and by early 2020 every major engine supported it.

Use the timeline below to step through the milestones.

  1. 1999 · The first attempt

    Behaviours in Internet Explorer

    Microsoft's HTML Components (.htc files) let developers bind script "behaviours" to ordinary elements through CSS, and later to custom tags. Powerful, but it only ever worked in one browser.

  2. 2001 · A browser built on bindings

    XBL at Netscape and Mozilla

    XBL (XML Binding Language) attached content, style and behaviour to elements, and was used to build much of Firefox's own interface. Its idea of hidden, bound content is a direct ancestor of Shadow DOM. A W3C successor, XBL 2.0, was never widely implemented.

  3. 2011 · The name arrives

    "Web Components and Model Driven Views"

    At the Fronteers conference in Amsterdam, Google's Alex Russell presented web components on a public stage for the first time: a family of specifications for custom elements, encapsulated "shadow" trees and templates.

  4. 2013 to 2014 · Version 0

    Chrome ships "v0", Polymer popularises it

    Chrome shipped the first versions of Custom Elements, Shadow DOM and HTML Imports, and Google's Polymer library made them approachable. Other browser makers held back, unconvinced by parts of the design. It was a useful, necessary experiment.

  5. 2016 · Consensus

    The "v1" specifications

    Browser vendors agreed on reworked versions of Custom Elements and Shadow DOM. Chrome and Safari shipped them in 2016. HTML Imports was dropped in favour of standard JavaScript modules.

  6. 2018 · Firefox and the enterprise

    Firefox 63, and Salesforce bets on standards

    Firefox shipped both v1 specifications. In December, Salesforce announced Lightning Web Components, moving one of the world's largest enterprise platforms onto web standards.

  7. 2020 · Universal support

    Every major browser engine

    Microsoft Edge moved to the Chromium engine in January, so Custom Elements and Shadow DOM v1 now worked in every major browser without polyfills. Chrome began retiring the experimental v0 APIs the same year.

  8. 2023 · Forms and scale

    Custom elements join real forms

    With Safari 16.4, form-associated custom elements (the ElementInternals API) worked across all major browsers, so a custom input can submit, validate and reset with a native <form>. Chrome's usage data that year showed custom elements on roughly one in five page loads.

  9. 2024 · Server rendering

    Declarative Shadow DOM becomes Baseline

    With Firefox 123, every major browser could build a shadow root straight from HTML, using <template shadowrootmode="open">. Encapsulated components can now be rendered on the server and appear before any JavaScript runs.

  10. 2026 · AEGOV

    The UAE Design System goes native

    Version 4 of the UAE Design System ships its full library as framework-agnostic web components, with a single aegov- vocabulary for federal entities, whether their stack is plain HTML, a CMS, React, Vue or Angular.

Interactive timeline: select a year, or focus the years and use the arrow keys, Home and End to move between milestones.

The lesson of that history is not that web components were slow to arrive. It is that standards outlast the tools built around them. Polymer, the library that carried the early versions, has long since been succeeded. The <button> element it was rendering has not changed. Components built on the platform inherit that longevity.


Who already relies on web components?

Web components are not a niche technology waiting for adoption. They are already behind some of the most heavily used interfaces on the web, often without anyone noticing, which is exactly the point.

  • YouTube rebuilt its desktop site on Google's Polymer library, making it one of the earliest large-scale deployments of custom elements.
  • GitHub uses small, focused custom elements throughout its interface. Its open-source <relative-time> element, which turns timestamps into "3 hours ago", is a textbook example of extending a native element rather than replacing it.
  • Adobe built the interface of Photoshop on the web with web components and the Lit library, using its Spectrum Web Components design system to bring together the work of many separate teams.
  • Salesforce moved its Lightning platform to Lightning Web Components in 2018, built on custom elements and Shadow DOM.
  • Ionic created Stencil, the compiler that generates standards-based web components, so its mobile UI toolkit could serve Angular, React and Vue developers from one codebase. The UAE Design System is built with Stencil too.

Notice the pattern. These are organisations with many teams, many products, and a long time horizon. That describes a federal government just as accurately.


How the UAE Design System uses web components

The UAE Design System ships 57 custom elements in its 4.0 library, from aegov-accordion to aegov-tooltip. You use them the way you use any HTML element: with tags, attributes and content.

<aegov-button variant="primary" appearance="solid" size="base">
  Apply for a permit
</aegov-button>

That markup is the entire public API. variant, appearance and size are attributes, exactly like type on a native <input>. Change an attribute and the component re-renders itself. Try it below with a live aegov-button, using controls that are themselves aegov-radio-group components.

Apply for a permit

<aegov-button variant="primary" appearance="solid" size="base">
  Apply for a permit
</aegov-button>
Live example: each choice sets an attribute on a real aegov-button. The markup below it is the only thing a developer writes, in any framework or none.

Encapsulation where it matters, openness where it helps

Not every AEGOV component uses Shadow DOM, and that is a deliberate design choice rather than an inconsistency. Of the 57 elements:

  • 18 render into Shadow DOM. These are mostly controls with internal structure that must not be broken by page styles: aegov-button, aegov-input, aegov-select, aegov-datepicker, aegov-modal and the other form fields.
  • 3 use Stencil's scoped mode, which emulates style isolation without a shadow root: aegov-dropdown, aegov-popover and aegov-toast.
  • 36 render in the light DOM, as part of the page. Content-led components such as aegov-card, aegov-accordion and aegov-badge stay open, so the text inside them can use your utility classes and site typography, and remains plain, indexable page content.

The demo below shows why encapsulation matters. On the left is an ordinary card built from page markup. On the right is the same card as a small custom element with its own shadow root. Turn on the conflicting stylesheet, the kind of thing a third-party widget or a careless global rule can introduce, and watch which card survives.

Light DOM card

Renew your Emirates ID

Estimated time: 5 minutes

Available online
Shadow DOM card

Live example: page selectors cannot reach inside a shadow root, so only the light DOM card is restyled. CSS custom properties, like design tokens, are inherited through the boundary on purpose, so both cards take the new accent.

That second toggle is the important one. Encapsulation is not a wall. It is a contract. A well-designed component exposes the things you are meant to change, through CSS custom properties (the same mechanism behind design tokens) and through named parts, while protecting the things you are not. aegov-button, for example, exposes its inner element as a part:

/* Reach a documented part of the component, and nothing else */
aegov-button::part(button) {
  letter-spacing: normal;
}

Built for forms, built for every stack

Eleven AEGOV components, including aegov-input, aegov-select, aegov-checkbox, aegov-otp and aegov-fileupload, are form-associated custom elements. They use the ElementInternals API to take part in a native <form> exactly as an <input> does: their values are submitted, they report validity, and they reset with the form. The validation guide shows how that works in practice.

And because a custom element is just an HTML element, the same components work in React, Vue and Angular, in a static page, or inside a CMS template. Stencil's loader also downloads a component's code only when that tag first appears on the page, so a page that uses three components does not pay for fifty-seven.


The benefits for government digital services

For a single product team, web components are a sensible engineering choice. For a federal government with dozens of entities, vendors and technology stacks, the benefits compound.

1. One component library, any technology stack

Entities do not need to standardise on one JavaScript framework to share one design system. A ministry running a CMS, an authority with a React portal and a vendor-built Angular application can all render the same aegov-input, with the same behaviour and the same accessibility. Procurement no longer has to dictate front-end architecture.

2. Consistency people can trust

When the button, the form field and the header come from one source, residents meet the same patterns on every service. That consistency is not cosmetic. It reduces the effort of learning each new service, an idea we explored in Cognitive Load Engineering.

3. Accessibility built once, inherited everywhere

Keyboard support, focus management, ARIA states, error messaging and right-to-left behaviour are hard to get right. In a shared component they are built once, tested once, and fixed once. Every service that upgrades inherits the fix. This is the most practical route to meeting the UAE Design System accessibility guidelines at scale.

4. Longevity and lower total cost

Frameworks have life cycles of a few years. Government services are expected to run for a decade or more. Components that depend only on browser standards keep working when the framework around them is replaced, which protects public investment and avoids costly rewrites. We return to this theme in The art of sustainable coding.

5. Faster delivery, including with AI tools

A clear, documented vocabulary of tags and attributes is easy for people to learn and easy for AI coding assistants to use correctly. The UAE Design System's MCP server gives those tools direct access to the component catalogue, so generated interfaces stay on-system. It is the same shift described in The Disappearing Handoff.

6. Safer integration of third-party content

Government pages often host widgets, analytics and embedded services from different suppliers. Shadow DOM keeps critical controls, such as a payment button or a consent form field, from being accidentally restyled or broken by CSS that someone else wrote.


The trade-offs worth knowing

A balanced view means naming the limits too. None of these are reasons to avoid web components, but each one shapes how they should be used.

  • JavaScript upgrades the element. Until a component's definition loads, the browser shows an undefined element. Reserve space for components, and use the :defined pseudo-class to avoid layout shift. Our guide to page speed testing covers how to measure this.
  • ARIA references stop at the shadow boundary. An aria-labelledby or for attribute cannot point to an ID inside another element's shadow root. That is why AEGOV form controls take their label, hint and error-message as attributes and wire them up internally. If ARIA is new to you, start with the vital role of ARIA.
  • Styling is an API, not a free-for-all. You cannot reach into a shadow root with any selector you like. Use the tokens, attributes and parts a component exposes. If you find yourself needing more, that is useful feedback for the design system.
  • Server rendering is newer. Declarative Shadow DOM made it possible across browsers in 2024, but support in frameworks and build tools is still maturing. Light DOM content, like the text inside a card, is already part of the page and fully indexable.

Conclusion

It took the web more than twenty years, three browser-specific experiments and a complete redesign to agree on a native component model. The result is quietly remarkable: a way to build a button, a date picker or a service card once, and have it work in every browser and every framework, for as long as the web exists.

For the UAE federal government, that changes the economics of quality. Accessibility, bilingual behaviour and consistency stop being something each team rebuilds, and become something every team inherits.

The UAE Design System is built on that foundation. Install it, explore the component library, and read our best practices for front-end development to get the most from it.


Further reading

Share this article

Back to top