This article possibly contains original research. (June 2021)
The topic of this article may not meet Wikipedia's general notability guideline. (June 2021)
Primary technologies used to create them include:
- Custom Elements: APIs to define new HTML elements
- Shadow DOM: encapsulated DOM and styling, with composition
There are two parts to Custom Elements: autonomous custom elements and customized built-in elements. Autonomous custom elements are HTML elements that are entirely separated from native HTML elements; they are essentially built from the bottom up using the Custom Elements API. Customized built-in elements are elements that are built upon native HTML elements to reuse their functionality.
Shadow DOM is a functionality that allows the web browser to render DOM elements without putting them into the main document DOM tree. This creates a barrier between what the developer and the browser can reach; the developer cannot access the Shadow DOM in the same way they would with nested elements, while the browser can render and modify that code the same way it would with nested elements. The impact of CSS scoped within the Shadow DOM of a particular element is that HTML elements can be encapsulated without the risk of CSS styles leaking and affecting elements that they were not supposed to affect. Although these elements are encapsulated with regard to HTML and CSS, they can still fire events that can be picked up by other elements in the document.
The scoped subtree in an element is called a shadow tree. The element the shadow tree is attached to is called a shadow host.
HTML template is a way to insert chunks of HTML that are stamped at will. The syntax of HTML templates looks like this:
<html> <template> <h1><slot name="title"></slot></h1> <p><slot name="description"></slot></p> </template> </html>
Scripts will not run, and resources that are inside a template will not be fetched until the template is stamped out.
Web Components are supported by all major browsers.
There are many libraries that are built on Web Components with the aim of increasing the level of abstraction when creating custom elements. Some of these libraries are X-Tag, Slim.js, Polymer, Bosonic, Riot.js, Salesforce Lightning Web Components, and DataFormsJS.
From the above list, Bosonic, Polymer, and DataFormsJS, provide ready-made components that are free to use. These components can be used interchangeably as they are all built on open web technologies.[clarification needed]
There are numerous community efforts for the Web Components ecosystem. WebComponents.org provides an interface to search for any existing Web Components, Custom Elements Everywhere validates whether popular front-end frameworks are compatible and ready to use Web Components standard, with a set of pending bugs and available workarounds. Moreover, Vaadin Tutorials has a dedicated section that shows how those workarounds are used efficiently with example demo apps and similarly related topics.
Web Components were introduced by Alex Russell at Fronteers Conference 2011 for the first time.
- GitHub - w3c/webcomponents: Web Components specifications., World Wide Web Consortium, 2019-01-03, retrieved 2019-01-03
- "Web Components". MDN Web Docs. Retrieved 2019-01-03.
- "<template>: The Content Template element". MDN Web Docs. Mozilla. Retrieved 2018-07-08.
- "Custom Elements". www.w3.org. Retrieved 2016-12-01.
- "What the Heck is Shadow DOM?". Dimitri Glazkov. 2011-01-15. Retrieved 2016-12-01.
- "Shadow DOM v1: Self-Contained Web Components | Web | Google Developers". Google Developers. Retrieved 2016-12-01.
- "Shadow DOM". Mozilla Developer Network. Retrieved 2016-12-01.
- Community. "Introduction to the template elements — WebComponents.org". webcomponents.org. Retrieved 2016-12-03.
- "webcomponents.org - Discuss & share web components". www.webcomponents.org. Retrieved 2020-07-22.
- "Web Components in production use – are we there yet?". vaadin.com. Retrieved 2016-11-21.
- "Search available Web Components".
- "Validate Front-end Frameworks with Web Components Standard".
- "Web Components Tutorials".
- "Web Components and Model Driven Views by Alex Russell · Fronteers". fronteers.nl. Retrieved 2016-12-02.
- "The state of Web Components ★ Mozilla Hacks – the Web developer blog". hacks.mozilla.org. Retrieved 2016-12-02.
- "Developer Tools support for Web Components in Firefox 63".
- Official website
- Web Components Specifications WICG
- Web Components at MDN Web Docs
- Browser Support for Custom Elements at Can I Use?
- Custom Elements Everywhere - Framework Support for Custom Elements
- Open Web Components
- What are Web Components?