IT lexicon › Web › Custom Element

Custom Element

Web På svenska → Updated: 2026-05-27

Web standard to define new HTML elements. customElements.define('my-button', class extends HTMLElement { ... }). Standardized 2018. Foundation for Web Components spec.

Native browser support in all modern browsers. Use: framework-agnostic component libraries (design systems that work in React + Vue + Angular). Microsoft Fluent UI, GitHub primer, Shoelace. Built-in lifecycle: connectedCallback, disconnectedCallback, attributeChangedCallback. Trade-off vs React/Vue: simpler for pure UI components, awkward for data-binding/reactivity (requires own state management). Modern frameworks: Lit (Google) is thin layer on top of custom elements + reactive props. Shadow DOM often used together for scoped CSS + DOM isolation.

← Back to the lexicon