Web Components in Easy Mode https://webcomponent.io
Find a file
ayo d97f7762cd
Some checks are pending
Tests / Unit (push) Waiting to run
Tests / E2E (push) Waiting to run
chore: update README.md re docs-review skill permission
2026-07-24 13:25:27 +02:00
.claude docs: update numbers 2026-07-24 11:14:06 +02:00
.github/workflows chore: remove workflow pnpm version requirement 2026-07-23 21:35:15 +02:00
.husky chore: use lint-staged for test & test:e2e precommit 2026-07-21 21:49:17 +02:00
.vscode feat: new cem analyzer plugin (cem-plugin) 2026-07-19 21:06:22 +02:00
assets chore: add todo-app example on readme 2023-12-27 22:11:59 +01:00
create feat(create): update template to latest wcb 2026-07-24 11:32:04 +02:00
demo docs: update numbers 2026-07-24 11:14:06 +02:00
docs docs: update numbers 2026-07-24 11:14:06 +02:00
scripts chore: update release script 2026-07-05 12:25:36 +02:00
src feat(cem-plugin): new distPaths plugin 2026-07-24 11:00:52 +02:00
storybook docs: align cem-plugin example with the typed-props pattern 2026-07-22 15:09:13 +02:00
test feat(cem-plugin): new distPaths plugin 2026-07-24 11:00:52 +02:00
vendors/htm chore: publish dist from root dir (#32) 2023-12-18 23:12:18 +01:00
.gitignore feat: new cem analyzer plugin (cem-plugin) 2026-07-19 21:06:22 +02:00
.npmignore chore: new demo workspace & e2e tests 2026-07-05 15:40:53 +02:00
.nvmrc chore: add .nvmrc 2026-07-05 12:17:31 +02:00
.prettierignore chore: set up prettier ignore 2024-12-27 11:10:32 +01:00
AGENTS.md docs: update numbers 2026-07-23 21:30:26 +02:00
CLAUDE.md chore: update agents instructions 2026-07-23 20:41:40 +02:00
eslint.config.mjs chore: use lint-staged for test & test:e2e precommit 2026-07-21 21:49:17 +02:00
LICENSE chore: add LICENSE file 2023-11-10 21:56:12 +01:00
package.json 6.1.4 2026-07-24 11:03:23 +02:00
pnpm-lock.yaml docs(demo): add the library-comparison counter demo 2026-07-22 23:41:52 +02:00
pnpm-workspace.yaml chore(create): rename workspace 2026-07-22 20:40:21 +02:00
prettier.config.mjs chore: use .mjs config files 2024-12-19 23:16:57 +01:00
README.md chore: update README.md re docs-review skill permission 2026-07-24 13:25:27 +02:00
size-change-log.md refactor: remove dead code 2026-07-24 05:51:27 +02:00
tsconfig.json chore: add rootDir in tsconfig 2026-05-08 14:44:20 +02:00
vitest.config.mjs chore: new demo workspace & e2e tests 2026-07-05 15:40:53 +02:00
vitest.e2e.config.mjs chore: add github test actions 2026-07-05 16:10:35 +02:00

Web Component Base

Note

HTML boolean attributes semantics shipped in v6 - A boolean prop follows the HTML convention in both directions: presence means true, absence means false. true reflects as a bare attribute and false removes it, so toggleAttribute() and [attr] CSS selectors finally work as expected.

Any present value is true — including the literal flag="false", just like native disabled="false" is still disabled. If you write boolean attributes as setAttribute(name, String(bool)), that now always means true; switch those call sites to toggleAttribute(name, bool). wcb warns in the console when it sees a boolean attribute written as "true"/"false" so the change cannot fail silently. Attributes whose "false" is meaningful (aria-*, contenteditable) should be declared as string props.

See Prop Access for details.

Package information: NPM version Package information: NPM license Package information: NPM downloads Bundle Size

🤷‍♂️ zero-dependency, 🤏 tiny JS base class for creating reactive custom elements easily

When you extend the WebComponent class for your component, you only have to define the template and properties. Any change in any property value will automatically cause just the component UI to render.

The result is a reactive UI on property changes.

Next actions:

  1. Read the docs
  2. View demos with code examples
  3. Play with a demo on CodePen.
  4. Try it on TypeScript playground

counter example code snippet

Want to get in touch?

There are many ways to get in touch:

  1. Open a GitHub issue or discussion
  2. Submit a ticket via SourceHut todo
  3. Email me: hi@ayo.run

Inspirations and thanks

  1. Sara Rainsberger - I never stop singing praises to the Astro documentation team and I use Sarah's "50 docs tips in 50 days" as a guide in reviewing the documentation for wcb. I do not have a team myself, and do not have the level of excellence Sarah brings to reviewing docs. I often need the assistance and have encodified a docs-review skill for it with permission.
  2. htm - I use it for the html function for tagged templates, and take a lot of inspiration in building the rendering implementation. It is highly likely that I will go for what Preact is doing... but we'll see.
  3. fast - When I found that Microsoft has their own base class I thought it was super cool!
  4. lit - lit-html continues to amaze me and I worked to make wcb generic so I (and others) can continue to use it

Size change log

See size-change-log.md for a running record of how each correctness/feature change affects the WebComponent base class bundle size, with the reason and benefit of each.

Background

This is the base class used for web components in Ayo's projects, primarily cozy-games, mcfly, his personal site, his blog, and others.


Just keep building.
A project by Ayo