frontend-web-components
Use when the user asks about custom elements, shadow DOM, slots and templates, ElementInternals, form-associated elements, declarative shadow DOM or…
от j4flmao★ 47 звёзд на GitHub
Установить frontend-web-components в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Web Components
Purpose
Build vanilla web components using the native Custom Elements API: encapsulated shadow DOM, typed lifecycle, form participation via ElementInternals, and cross-framework compatibility patterns.
Agent Protocol
Trigger
Exact user phrases: "web component", "custom element", "shadow DOM", "HTML template", "CustomElementsRegistry", "ElementInternals", "form-associated element", "cross-framework component", "vanilla web component".
Input Context
Before activating, verify:
- No Lit, Stencil, or other web component library in dependencies.
- Whether the component needs shadow DOM or light DOM.
- Whether the component participates in a form (ElementInternals).
- Target browsers (check CustomElementRegistry and ElementInternals support).
Output Artifact
No file output. Produces element design, encapsulation strategy, framework integration as text.
Response Format
Element Design: {name} — {purpose}
Encapsulation: {open shadow DOM / closed / light DOM}
Framework Integration: {attribute reflection, event mapping}
No preamble. No postamble. No explanations. No filler/hedging/transitions. Compress output — why use many token when few do trick.
Completion Criteria
- Custom element registered via customElements.define() with kebab-case name.
- Lifecycle methods implemented (connected, disconnected, attributeChanged).
- observedAttributes defined for reactive attribute sync.
- Properties reflect to attributes and vice versa.
- Shadow DOM used for style encapsulation (open mode).
- ElementInternals used if form-associated.
- Framework wrappers provided or documented for React/Vue/Angular.
- DisconnectedCallback cleans up event listeners and observers.
Max Response Length
2560 tokens.
Web Component Architecture / Decision Trees
Architecture Decision Tree
Is this a reusable component shared across frameworks?
|-- YES --> Web Components (framework-agnostic by nature)
| Use case: design system components, shared widgets
|
|-- NO, single framework only -->
|-- Using React? --> React component (simpler, better DX)
|-- Using Vue? --> Vue SFC (simpler, better DX)
|-- Using Angular? --> Angular component (simpler, better DX)
|-- Vanilla JS project? --> Web Component
Shadow DOM Decision Tree
Does the component need style encapsulation?
|-- YES -->
| |-- Needs to be accessible from outside for testing? -->
| | YES: attachShadow({ mode: 'open' })
| | NO: attachShadow({ mode: 'closed' }) — rare, breaks tooling
| |
| |-- Content projection needed? -->
| Use <slot> elements in shadow DOM template
|
|-- NO -->
Light DOM (no shadow root, styles are global)
Simpler, but CSS can leak in/out
Form-Associated Decision Tree
Does the component represent a form value?
|-- YES (input, select, checkbox, custom file picker) -->
| Set static formAssociated = true
| Use attachInternals() for form participation
| Update value: _internals.setFormValue(val)
| Report validity: _internals.setValidity(flags)
|
|-- NO (button, tooltip, accordion, card) -->
Regular custom element, no form involvement
Cross-Framework Wrapper Decision Tree
What framework consumes this component?
|-- React -->
| Wrapper: useRef + useEffect to set properties/attributes
| Events: addEventListener in useEffect, cleanup in return
| Complex props: set via element.property (not attribute)
|
|-- Vue -->
| Wrapper: template with :prop binding + @event handler
| v-model: implement with :value + @input pattern
|
|-- Angular -->
| Wrapper: CUSTOM_ELEMENTS_SCHEMA for template
| or Angular wrapper component with ElementRef
Workflow
Step 1: Custom Element Lifecycle
class BaseElement extends HTMLElement {
constructor() {
super()
this._internals = this.attachInternals?.()
}
connectedCallback() {
this._render()
this._addListeners()
}
disconnectedCallback() {
this._removeListeners()
}
attributeChangedCallback(name, oldValue, newValue) {
if (oldValue !== newValue) this._render()
}
adoptedCallback() {
this._render()
}
}
Four lifecycle hooks: constructor → connected → disconnected → attributeChanged. adoptedCallback fires when element moves between documents.
Step 2: Attributes & Properties
class UserAvatar extends HTMLElement {
static get observedAttributes() {
return ['src', 'alt', 'size']
}
get src() { return this.getAttribute('src') ?? '' }
set src(val) { this.setAttribute('src', val) }
get alt() { return this.getAttribute('alt') ?? '' }
set alt(val) { this.setAttribute('alt', val) }
get size() { return parseInt(this.getAttribute('size') ?? '40') }
set size(val) { this.setAttribute('size', String(val)) }
constr
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/custom-elements.md
- references/shadow-dom.md
- references/wc-performance.md
- references/wc-testing.md
- references/web-components-frameworks.md
- references/web-components-implementation.md
FAQ
Что делает скилл frontend-web-components?
Use when the user asks about custom elements, shadow DOM, slots and templates, ElementInternals, form-associated elements, declarative shadow DOM or framework-free cross-framework components. Produces standards-based web components. Not for Lit (use frontend-lit) or Stencil (use stencil).
Как установить скилл frontend-web-components?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл frontend-web-components запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
AnthropicGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
webapp-testing
AnthropicToolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
brand-guidelines
AnthropicApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
web-artifacts-builder
AnthropicSuite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…