Skip to content
Back to skills

Web Component Design

ASecurity

Use when building reusable web components.

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 10, 2026
ai-agentsjavascriptjavaapifrontend

Works with

  • cli
  • api

Security analysis

A100/100

Scanned September 10, 2026

npx -y skills add LoopyLuci/Skills --skill web-component-design --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Web Component Design?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Web Component Design
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/loopyluci-web-component-design/badge)](https://www.skillsdirectory.com/skills/loopyluci-web-component-design)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: web-component-design
description: "Use when building reusable web components."
version: 1.0.0
author: Hermes Agent
license: MIT
metadata:
  hermes:
    tags: [web-components, custom-elements, shadow-DOM, HTML-templates, reusable]
    related_skills: [frontend-bootstrap, responsive-web-design-patterns, graphql-client-patterns, web-accessibility-practices]
---

# Web Component Design

Building reusable web components using Web Components standards — Custom Elements, Shadow DOM, HTML Templates, lifecycle hooks, and framework-agnostic design.

## When to Use

- Building framework-agnostic reusable UI components
- Creating design system components that work anywhere
- Encapsulating component styles with Shadow DOM
- Building micro-frontends with shared components

## Component Lifecycle

```javascript
class BaseComponent extends HTMLElement {
    constructor() { super(); this.attachShadow({ mode: 'open' }); }
    connectedCallback() { this.render(); this.addListeners(); }
    disconnectedCallback() { this.removeListeners(); }
    attributeChangedCallback(name, oldVal, newVal) { if (oldVal !== newVal) this.render(); }
    static get observedAttributes() { return ['data-label', 'data-disabled']; }
    
    render() {
        this.shadowRoot.innerHTML = `
            <style>:host { display: block; }</style>
            <div part="container">${this.getAttribute('data-label')}</div>
        `;
    }
}
customElements.define('base-component', BaseComponent);
```

## Common Pitfalls

1. **Over-styling** — Shadow DOM hard to customize; use CSS custom properties and ::part
2. **Form participation** — custom elements need ElementInternals for form integration
3. **Accessibility** — ARIA roles and keyboard navigation aren't automatic
4. **Over-abstraction** — not everything needs to be a web component

## Verification Checklist

- [ ] Lifecycle properly implemented
- [ ] Shadow DOM for style encapsulation
- [ ] CSS custom properties for theming
- [ ] Attribute/property API documented
- [ ] Accessibility (ARIA, keyboard, focus)
- [ ] Tested in multiple frameworks

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…