diff --git a/skills-drafts/web-components/SKILL.md b/skills-drafts/web-components/SKILL.md new file mode 100644 index 00000000..130f7995 --- /dev/null +++ b/skills-drafts/web-components/SKILL.md @@ -0,0 +1,507 @@ +--- +name: web-components +description: Action-oriented guidelines for authoring and using Web Components (Custom Elements, Shadow DOM, and HTML Templates). Use this skill when creating reusable UI components, implementing design systems, or managing component lifecycle and styling isolation. +--- + +# Web Components + +Web Components are a collection of different specifications, allowing the creation of reusable custom elements with their functionality and styling encapsulated away from the rest of the document. These assets can be published and used in any web application, regardless of the framework or library used. These technologies are leveraged in the modern web development landscape to create reusable UI components, design systems, and manage component lifecycle and styling isolation. + +## Table of Contents + +1. [Glossary](#1-glossary) +2. [Decision Matrix: Choosing Web Component Features](#2-decision-matrix-choosing-web-component-features) +3. [Custom Elements](#3-custom-elements) + 3.1 [Lifecycle Management](#31-lifecycle-management) + 3.2 [Implementation Guidelines](#32-implementation-guidelines) +4. [Shadow DOM & Encapsulation](#4-shadow-dom--encapsulation) + 4.1 [Encapsulation Strategies](#41-encapsulation-strategies) + 4.2 [Styling & Theming](#42-styling--theming) +5. [Styling Web Components](#5-styling-web-components) + 5.1 [The :host Pseudo-class](#51-the-host-pseudo-class) + 5.2 [Slots and ::slotted Content](#52-slots-and-slotted-content) + 5.3 [Style Inheritance and CSS Custom Properties](#53-style-inheritance-and-css-custom-properties) + 5.4 [Methods for Loading Stylesheets](#54-methods-for-loading-stylesheets) + 5.5 [The ::part() Pseudo-element](#55-the-part-pseudo-element) +6. [Semantics, Accessibility, and Forms](#6-semantics-accessibility-and-forms) + 6.1 [Shadow DOM and ARIA](#61-shadow-dom-and-aria) + 6.2 [Form-Associated Custom Elements (FACE)](#62-form-associated-custom-elements-face) +7. [HTML Templates and Slots](#7-html-templates-and-slots) +8. [Performance](#8-performance) + 8.1 [Performance Bottlenecks](#81-performance-bottlenecks) + 8.2 [Optimization Strategies](#82-optimization-strategies) + 8.3 [Measuring Component Performance](#83-measuring-component-performance) + +## 1. Glossary + +| Term | Definition | +| :--- | :--- | +| **Custom Element** | A user-defined HTML tag that extends the standard set of HTML elements via the `customElements.define()` API. | +| **Shadow DOM** | A "lite" version of the DOM that is attached to an element but separated from the main document DOM, providing style and markup encapsulation. | +| **Shadow Root** | The root node of a Shadow DOM subtree. It is attached to a "shadow host." | +| **Shadow Host** | The regular DOM node that the Shadow DOM is attached to. | +| **Light DOM** | The regular DOM inside an element that is *not* part of its Shadow DOM. This is where slotted content lives. | +| **Autonomous Custom Element** | A custom element that extends the base `HTMLElement` class (e.g., ``). | +| **Customized Built-in Element** | A custom element that extends a specific native element (e.g., `