Open-source project
mdn/web-components-examples avatar
mdn/web-components-examples

mdn/web-components-examples is fifteen folders of standalone demos, and the README lists only twelve

A series of web components examples, related to the MDN web components documentation at https://developer.mozilla.org/en-US/docs/Web/Web_Components.

3,385 stars814 forksJavaScriptCC0-1.0

At a glance

What is it?
mdn/web-components-examples is a CC0-1.0 repository of small web component demos that back the MDN documentation. Each demo is a folder with a live page, there is nothing to install, and three folders are missing from the README index.
Who is it for?
Use mdn/web-components-examples to read small, single-purpose demos of custom elements, shadow DOM, templates and slots alongside the MDN pages that explain them. Do not use it as a component library or a framework comparison, since it is a set of teaching examples with no package.
Can I use it commercially?
Yes. CC0-1.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 48 days ago.
What is it written in?
Mainly JavaScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 24, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • mdn/web-components-examples3,385 ★ · +8
Star history
Repository2026-10-082026-11-24
mdn/web-components-examples3.4k3.4k

8 Stars in the last 47 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

Each folder is a self-contained demo with a live page on mdn.github.io

The repository is a series of Web Components examples tied to the MDN Web Components documentation. There is no build step, no package and no install section in the README. Every example is a directory at the top level, and each one links to a live version at mdn.github.io/web-components-examples followed by the folder name, for instance composed-composed-path or slotchange.

That structure makes the repository a reading exercise. You open the folder, read the JavaScript and HTML, and compare it against the live page. The live pages are served from the same repository, so what you see in the browser matches the files you can read on GitHub.

The address pattern for any demo is:

code
https://mdn.github.io/web-components-examples/composed-composed-path/

The license is CC0-1.0, so you can copy the code into your own project without attribution. The repository is not archived, it has no GitHub releases, and the last push was on 2026-10-07.

Fifteen demo directories exist and the README index names twelve

The README lists twelve examples: composed-composed-path, defined-pseudo-class, editable-list, edit-word, element-details, expanding-list-web-component, life-cycle-callbacks, popup-info-box-web-component, simple-template, slotchange, slotted-pseudo-element and word-count-web-component.

The top level has more. host-selectors, popup-info-box-external-stylesheet and shadow-part are directories with no entry in that list. Their names suggest what they cover, with host selectors, an external stylesheet variant of the popup info box and the shadow part feature, but the README does not describe them, so open each folder to confirm.

The consequence is that browsing the README alone misses material. The README also carries two different MDN addresses: the introduction links to the Web API page for Web components and the description field to the Web Components guide.

Autonomous elements and customized built-ins use different syntax in these demos

Two kinds of custom element appear in the examples, and the difference changes the HTML you write. An autonomous custom element has its own tag. element-details is one: it displays a box with an HTML element name and description, gets its structure from a template element that has its own styling, and contains slot elements filled at runtime.

A customized built-in element extends a native element and is used through the is attribute. expanding-list-web-component is written as ul is="expanding-list", and its class inherits from HTMLUListElement rather than HTMLElement. word-count-web-component does the same with HTMLParagraphElement. The README highlights this inheritance in both descriptions.

For a reader, the choice has a practical edge. The class declarations in the demos differ by the base class: HTMLElement for autonomous elements, HTMLUListElement or HTMLParagraphElement for the customized ones.

Shadow DOM, template and slot demos each isolate one mechanism

popup-info-box-web-component creates an info icon that shows a popup info box when focused. It takes information from its img and text attributes and defines structure and basic style in an attached shadow DOM. The sibling folder popup-info-box-external-stylesheet exists beside it, though the README does not index it.

simple-template is described as a trivial example of the template and slot elements. element-details expands that to a custom element built from a template. slotchange is the more involved one: summary-display takes two slot values, a list of possible choices and a description for the selected choice. Several paragraphs sit inside the element, and clicking a choice gives its matching paragraph the slot attribute so it appears in the second slot. The demo exists to show the slotchange event and features of the HTMLSlotElement interface.

word-count is the demo with a timer. It counts the words inside the element it is added to, shows them inside an attached shadow DOM, and has an interval that periodically updates the count as the content changes.

Event and CSS behaviour is shown through composed, defined and slotted demos

composed-composed-path is a very simple example of how the composed and composedPath properties of the Event object behave. It is the demo to open when events fired inside a shadow tree do not reach listeners outside it, because it isolates exactly those two properties.

defined-pseudo-class shows how the :defined pseudo-class works, with a link to its MDN CSS reference page. It is the one to read if you need to style a custom element differently before its definition has been registered. slotted-pseudo-element does the same for ::slotted, which styles content assigned to a slot.

Each of these is described as very simple, and that is the point. They are one idea per folder, so they work as reference snippets. None of them tries to be an application, and the README does not claim they are production patterns. The shadow-part and host-selectors folders have no README description.

Lifecycle callbacks and editing demos need user interaction to show anything

life-cycle-callbacks is a trivial custom-square element, written as custom-square with l and c attributes, that creates a coloured square box. The demo adds buttons to create it, destroy it and change its attributes, so you trigger the lifecycle callbacks by hand and watch what runs. The README links this demo to the MDN section on using the lifecycle callbacks.

edit-word wraps one or more words in an element. Clicking or focusing the element reveals a text input that edits the words. editable-list builds a list with addable and removable items: items arrive through a list-item attribute, or by entering text and clicking the plus sign.

These are the demos that behave like small interfaces, and they depend on interaction in a browser. You cannot judge them by reading the code alone, so use the live page. They also give a sense of attribute handling, since list-item, img, text, l and c are the attributes that drive these elements.

The repository has contribution rules and a security policy but no test or tooling files

The README asks contributors to read the contribution guidelines before contributing. The top level includes CONTRIBUTING.md, CODE_OF_CONDUCT.md, SECURITY.md, a LICENSE file, a .github directory and a .gitignore. No package.json, lockfile, bundler config or tests directory appears in the top-level listing.

That absence tells you how the demos run: the examples are plain files served directly. You will not find a framework, a build command or a dependency to update.

For learning, this is an advantage, since the code you read is the code that runs. For anyone hoping to find a component set to depend on, it is the wrong repository.

Editorial conclusion

Use mdn/web-components-examples to read small, single-purpose demos of custom elements, shadow DOM, templates and slots alongside the MDN pages that explain them. Do not use it as a component library or a framework comparison, since it is a set of teaching examples with no package. Before copying a demo, check whether it is an autonomous element or a customized built-in, because customized built-ins use the is attribute.

Frequently asked questions

What are web components, according to mdn/web-components-examples?

The repository is a series of Web Components examples that relate to the MDN Web Components documentation. The demos cover custom elements, shadow DOM, templates and slots.

Can you give me an example of a web component from mdn/web-components-examples?

popup-info is one: it creates an info icon that shows a popup info box when focused, takes img and text attributes, and defines structure and basic style in an attached shadow DOM.

What is a component example in mdn/web-components-examples?

word-count is one: it counts the words inside the element it is added to and shows the total in an attached shadow DOM. It has an interval that updates the count as the content changes.

What are components in HTML, as shown in mdn/web-components-examples?

The examples include autonomous custom elements such as element-details and customized built-in elements such as ul is="expanding-list", whose class inherits from HTMLUListElement.

Official sources

  1. Issues
  2. License: CC0-1.0
  3. mdn/web-components-examples on GitHub
  4. README
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/mdn-web-components-examples.svg)](https://hysenlabs.com/projects/mdn-web-components-examples)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/mdn-web-components-examples.svg)](https://hysenlabs.com/projects/mdn-web-components-examples)

Was this useful?