Skip to content

docs: add front-end/web-components.md #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions docs/front-end/web-components.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Web Components

The [WHATWG](https://html.spec.whatwg.org/multipage/custom-elements.html) and [WICG](https://github.com/WICG/webcomponents) maintain suite of web technologies and specifications including (but not limited to)

- [Custom Elements](https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements)
- [Shadow DOM](https://dom.spec.whatwg.org/#shadow-trees)
- The [`<template>` element](https://html.spec.whatwg.org/multipage/scripting.html#the-template-element)
- The [`<slot>` element](https://html.spec.whatwg.org/multipage/scripting.html#the-slot-element)
- [`ElementInternals`](https://html.spec.whatwg.org/multipage/custom-elements.html#element-internals)
- [CSS Custom Properties](https://drafts.csswg.org/css-variables/)
- [Module scripts](https://html.spec.whatwg.org/#module-script)

These are collectively referred to as "web components", and represent the browsers' native component model for web developers.

Broadly speaking, every web component is a custom element - a specific, globally-recognized tag-name which becomes associated with a class extending HTMLElement in JavaScript. Web components can also make use of the related technologies.

## Recommended Components

- [Lit](https://lit.dev) (for authoring components)
- [Web Dev Server](https://modern-web.dev) / Web Test Runner (for unit tests and local dev)
- [Custom Elements Manifest](https://github.com/webcomponents/custom-elements-manifest) (for ide support / docgen / codegen)
- [PatternFly Elements](https://patternflyelements.org) Design System
- [Carbon Web Components](https://web-components.carbondesignsystem.com/) Design System

## Guidance

### Advantages and Ideal Use Cases

- mix and matching components
- a la carte / low impact development
- cross-team collaboration
- design systems
- migrating piecemeal from older frameworks

### Potential Gotchas When Using Web Components

- cross-root aria
- double-registration errors
- server-side tooling / ssr limitations
- shadow dom can be a double edged sword

### Our Experiences Using Web Components at Red Hat

- Design Systems
- PFE
- RHDS
- HTML-first / MPAs
- SPA usage (high javascript, state-management)

## Further Reading