β οΈ Warning: This library is unstable and still under active development. APIs may change without notice. Use at your own risk in production environments.
A lightweight, reactive library for building web applications using a declarative syntax. XynHTML is inspired by jQuery, but focuses on simplicity and performance with built-in reactive signals.
- Reactive Signals: Create reactive data that automatically updates the UI
- Effects: Run side effects when signals change
- Derived Values: Compute values based on other signals
- Declarative Components: Build UI components with tagged template literals using
tagfunction - Conditional Rendering: Show/hide elements based on signal values
- Form Validation: Build reactive forms with real-time validation
- No Build Step: Works directly in the browser with ES modules
Below is the current implementation status of XynHTML's planned features:
- β Signal System - Basic reactive state management with subscription/notification
- β Effect System - Automatic side effect execution when signals change
- β Derived Values - Computed signals that update based on dependencies
- β DOM Element Components - Function for creating reactive HTML elements
- β Dynamic Text Rendering - Template literal text nodes with signal interpolation
- β Switch DOM Elements - Container for creating reactive switcher of multiple HTML elements
- β HTML Fragments - Document fragment support for efficient DOM updates
- π₯ Map an Iterable to Elements - Utilize a list signal to reactively generate updates to a list of elements
- β
CSS Selector Based Component Creation - Function for creating a whole HTML node tree by using a syntax like CSS selectors
- β HTML DOM Elements - Creating a basic HTML element and setting CSS classes, IDs, attributes, and events
- β Text Nodes - Adding text nodes with reactive text
- π₯ Switch Element - Make a switchable container that reactively selects an element
- π₯ List of Elements - Generate a list of elements based on a reactive list
- π₯ List Signal - Reactive arrays with built-in list operations
- π₯ Map Signal - Reactive key-value stores with object-like interface
- βοΈ Route Signal - Reactive state management based on page route, this will parse the query parameters
- βοΈ Animation Signal - Reactive state management based on the last animation state
- βοΈ Transition Signal - Reactive state management that returns the last state of transitions
- π§ Code Parser with Syntax Highlighting - Parse and highlight JavaScript, HTML, CSS, and other languages within XynTag components
- π§ Widget System - Pre-built reactive components (buttons, forms, modals, tooltips, etc.) for rapid development
- π§ Button - A simple syntax for creating the different types of buttons
- π§ Input - Support all kinds of text input with a single function
- π§ Check/Radio - Made as an easy way to add selectable elements
- π§ Dropdown List - Create dropdown lists that support single value and multiple values
- π§ Slider - Add and extend sliders with reactive data
- π§ Time and Date - Reactive clocks and calendars
- π§ Combo Lists - Add a text input to any control with reactive values
- π§ Tooltips - Add reactive tooltips and error messages to other reactive elements
- π§ Windows - Dialog windows that are modal and free floating are handled with this control
- π§ Layout Container - A reactive container designed to be used with the Theme Manager
- π§ Theme Manager - A reactive and injected set of styles based on community developed themes
- π§ Client-Side Routing - Hash-based and history API routing for single-page applications
- π§ Route Parameters - Dynamic route segments with parameter extraction
- π§ Route Guards - Authentication and authorization checks before route activation
- π§ Nested Routing - Hierarchical route structures for complex applications
- π§ Route Transitions - Animated transitions between routes with lifecycle hooks
- β Implemented - Feature is complete and functional
- π₯ Planned - Feature is planned but not yet implemented
- βοΈ In Progress - Feature is currently being worked on and is completely untested
- π’ Wishlist Completed - Wishlist feature that has been implemented
- π§ Wishlist Incomplete - Wishlist feature ideas that might be completed in the future, but no commitment is made
- Import XynHTML in your project:
import { signal, effect, derived, tag, text, mountNext, mountRoot } from "./xyn_html.js";- Create reactive signals:
const counter = signal(0);
const message = signal("Hello World!");- Build UI components:
const button = tag`button`;
button.children.add(text`Count: ${counter}`);
button.event.add("click", () => counter.value++);
mountNext(button, document.body);Signals are reactive data containers that notify subscribers when their value changes:
const name = signal("John");
name.value = "Jane"; // Triggers updatesEffects run functions when dependent signals change:
const unsubscribe = effect(() => {
console.log(`Name is: ${name.value}`);
}, [name]);Create computed values that update automatically:
const fullName = derived(() => {
return `${firstName.value} ${lastName.value}`;
}, [firstName, lastName]);
// Clean up when done
fullName.unsubscribeDerived();Build HTML elements with reactive content:
const container = tag`div`;
const title = tag`h1`;
title.children.add(text`Welcome, ${userName}!`);
container.children.add(title);
mountNext(container, "body"); // Can also get the by selector stringsTo see XynHTML in action with comprehensive examples, visit the examples page in this repository. The examples cover:
- Basic signal usage and subscription
- Multiple signals and effects
- Derived values and computed properties
- Complex state management
- DOM creation and manipulation
- Conditional rendering
- Form validation
- Performance optimization
- Theme switching
Creates a new reactive signal.
Runs a callback when any of the dependency signals change.
Creates a computed signal that updates based on other signals. Returns a signal with an additional unsubscribeDerived() method for cleanup.
Creates a new HTML element component.
Creates reactive text content with signal interpolation.
Both mount a component to a DOM element, with the only difference of mountRoot will clear the contents and then mount it, and mountNext just appends it.
- unsubscribeDerived(): Cleans up the derived signal's internal effect subscription.
XynHTML works in all modern browsers that support ES modules and Proxy objects:
- Chrome 61+
- Firefox 60+
- Safari 10.1+
- Edge 16+
- Clone or download this repository
- Open
index.htmlin your browser to see the examples - Start building your own reactive applications with XynHTML!
This project is licensed under the MIT License - see the LICENSE file for details.