Next-generation Web Component framework leveraging TypeScript Stage 3 standard decorators.
npm install @o.z/zui



ZUI is a next-generation, lightweight abstraction layer for building native Web Components. It leverages TypeScript Stage 3 Decorators to eliminate boilerplate, manage reactive state, and streamline DOM interactions while staying close to the metal of the browser.
---
Standard Web Components require significant boilerplate: managing observedAttributes, manually handling shadowRoot, and verbose event dispatching. ZUI solves this with a declarative, type-safe API:
* β‘ Stage 3 Decorators: Built for modern TypeScript, utilizing the standard --- `` --- ZUI is designed to work seamlessly with Viteβs raw and inline string imports for templates and styles. ` export type CounterClickEvent = { count: number; e?: MouseEvent } @defineElement({ // 2. DOM References: Automatically queried from Shadow Root @ref(".btn-inc") // 3. Event Emitter: Typed event dispatcher connected() { // 4. Reactive Hook: Called when 'count' changes Since we extended the native div ` --- --- ` --- The authors of this software consider the use of this code, including its source code, documentation, and any other project artifacts, for the training of artificial intelligence (AI) systems (including but not limited to machine learning, large language models, and other AI technologies) to be creating a derivative work. As such, any entity using this code for such purposes must comply with the terms of the GPLv3. This includes, but is not limited to, making the entire source code of the AI system that uses this code available under the same GPLv3 license. If you wish to use this code for AI training without being subject to the GPLv3, please contact the authors to negotiate a separate license.accessor pattern.
* π Reactive State: Properties automatically trigger view updates and lifecycle hooks.
* π― Zero-Boilerplate Refs: Type-safe DOM element caching without manual querySelector calls.
* π‘ Magic Event Emitters: Auto-generated, strictly typed event dispatch methods.
* π¨ Scoped Styling: Seamless integration with standard Shadow DOM or scoped styles.
* π Customized Built-ins: First-class support for extending native elements (e.g., ).π¦ Installation
bash`
npm install @o.z/zuior
yarn add @o.z/zuior
pnpm add @o.z/zuiπ οΈ Usage Example
$3
typescript
import { defineElement, event, property, ref, Zui, EventEmitter } from "@o.z/zui"
import htmlStr from "./counter.html?raw"
import cssStr from "./counter.scss?inline"
tagName: "my-counter",
html: htmlStr,
css: cssStr,
options: { extends: 'div' } // Extend native div functionality
})
export class Counter extends Zui(HTMLDivElement) {
// 1. Reactive State: Synchronized with 'count' attribute
@property()
accessor count = 0
@ref(".counter-display")
displayRef!: HTMLDivElement
incBtn!: HTMLButtonElement
@event()
counterClick!: EventEmitter
this.incBtn.addEventListener("click", () => {
this.counterClick.emit({ count: 1 })
})
}
countUpdate(oldValue: number, newValue: number) {
this.displayRef.innerHTML = newValue.toString()
}
}
`$3
, we use the is attribute:html
Increment
`π API Reference
API Docsπ» Development
bashInstall dependencies
yarn installStart development server
yarn devBuild the library
yarn build
``License and AI Training
This project is licensed under the GNU General Public License v3.0 (GPLv3).