o
odinpkg.dev
packages / library / jsgui-2

jsgui-2

5cda63alibrary

A faster replacement for React. - deprecated: use https://github.com/Patrolin/jsreact instead

Unlicense · updated 9 months ago

jsgui-2

A faster replacement for React.

Usage

<head>
  <link rel="stylesheet" href="../src/jsgui.css" />
  <script type="module" src="demo.mjs"></script>
</head>

app.mjs

import { div, span, button, useState, renderBody } from "../src/jsgui.mjs";

/**
 * @param {Component} body */
function App(body) {
  const [state, changeState] = useState(body, "App", {clicks: 0});

  const row = div(body, {padding: 8, flex: "x", columnGap: 8});
  span(row, `Clicks: ${state.clicks}`);
  if (button(row, "Press me!", {margin: "0"}).pressed) {
    changeState({clicks: state.clicks + 1});
  }
}
renderBody(App, { background: "#0f0f0f", scrollY: true, color: "white" });

Open demo

Docs (WIP)

https://patrolin.github.io/jsgui-2/