UIElement Docs Version 0.12.0

📖 Introduction

Web development doesn't need to be complicated. UIElement offers a refreshingly simple approach to create reactive Web Components that enhance your existing HTML.

What is UIElement?

UIElement is a lightweight TypeScript library (approximately 4kB gzipped) that brings signal-based reactivity to Web Components. It serves as a thin layer between standard web technologies and modern reactivity patterns, empowering you to:

js

import { asInteger, component, first, on, RESET, setText } from '@zeix/ui-element'

component('show-appreciation', {
    count: asInteger(RESET) // Get initial value from .count element
}, el => [

	// Update count display when state changes
    first('.count', setText('count')),

    // Handle click events to change state
    first('button', on('click', () => { el.count++ }))
])

UIElement augments what the platform already provides. It leverages the Web Components standard while adding just enough convenience functions to make reactive UI behaviors easy to implement.

Philosophy & Design Goals

HTML-First Approach

While many frameworks start with JavaScript and generate HTML, UIElement takes the opposite approach. It assumes you already have HTML (whether server-rendered or manually created) and want to enhance it with behavior:

html

<!-- Start with semantic HTML -->
<show-appreciation aria-label="Show appreciation">
    <button type="button">
        <span class="emoji">💐</span>
        <span class="count">5</span>
    </button>
</show-appreciation>

This philosophy means:

Performance By Design

UIElement avoids the overhead of virtual DOM diffing, instead using precise, targeted DOM updates through a fine-grained reactivity system:

Developer Experience Without Compromise

UIElement is designed to be intuitive and easy to use. It's built with type safety in mind, ensuring that your code is correct and that you don't miss any potential bugs.

Why UIElement?

While there are many excellent JavaScript frameworks out there, UIElement embraces web standards without proprietary extensions. It deliberately eschews abstractions like HTML-in-JS (client-side rendering) or JS-in-HTML (logic in framework-specific attributes) in favor of directness. It does JavaScript state management and view updates the hard way, while still providing the benefits of declarative reactivity with a few functions to compose complex behavior.

UIElement differentiates itself through:

UIElement shines when:

Next Steps

Now that you understand what UIElement is and its core philosophy, you're ready to: