Skip to main content

JavaScript API

Add interactivity with components, actions, stores, and directives.

Installation

import uizy from "@dufeut/uizy";
import "@dufeut/uizy/index.css";

Quick Start

uizy.start({
// Components (reusable CSS classes)
components: {
button: {
primary: () => "px-4 py-2 bg-blue-500 text-white rounded",
},
},

// Actions (event handlers)
actions: {
user: {
login: (data) => console.log("Login:", data),
},
},

// Stores (reactive state)
stores: {
user: {
name: uizy.store.atom("Guest"),
},
},

// Ready callback
onReady: () => console.log("Uizy ready!"),
});

Core Concepts

FeaturePurposeAccess
ComponentsReusable CSS class generatorsuizy.use("path")
ActionsEvent handlers & side effectsuizy.emit("path")
StoresReactive state managementuizy.$("path")
DirectivesCustom HTML attributesu-name="value"
PluginsBundled, namespaced modulesuizy.plugin()

API Quick Reference

Configuration

MethodDescription
uizy.start(config)Initialize with full configuration
uizy.layout(config)Configure layout dimensions
uizy.theme(config)Configure colors and styles

Components

MethodDescription
uizy.use(path, props?)Get CSS classes from component
uizy.add(items)Register components

Actions

MethodDescription
uizy.emit(path, payload?)Call an action
uizy.on(items)Register actions

Stores

MethodDescription
uizy.$(path)Get store value
uizy.$set(path, value)Set store value
uizy.$sub(path, fn)Subscribe to changes
uizy.state(items)Register stores

Directives

MethodDescription
uizy.directive(name, handler)Register a directive

Next Steps