NewTypes that flow through JSX

Effect UI components, written as plain TSX.

A model for the state, a controller for everything that can happen, and a view that is just TSX. It is all typed from the model outwards, and every panel on this page is one.

counter.tsx
import { component, controller, model, type View } from "effect-ui-tsx"const counterModel = model({ count: 0 })const counterController = controller(counterModel).actions(({ on, reset }) => ({  increment: on({}, (state) => ({ count: state.count + 1 })),  restart: reset("count"),}))const CounterView: View<typeof counterController> = ({ state, action }) => (  <div>    <button type="button" onClick={action.increment}>      Clicked {state.count} times    </button>    <button type="button" disabled={state.count === 0} onClick={action.restart}>      Restart    </button>  </div>)export const Counter = component({  name: "Counter",  controller: counterController,  view: CounterView,})
LiveBrowserHost

The component on the left, running. Its messages show up in the message log below, and in the devtools in the corner.

  • Works with no tooling

    A JSX runtime and three functions. Any bundler that handles TSX works as it is.

  • An optional compiler

    Declare module({ name }) and it finds the model, controller and view by convention.

  • Typed from the model outwards

    State, actions and payloads are inferred, and effect-ui-tsx-check follows them through JSX.

  • Rendered, then hydrated

    Render features to HTML and adopt them in the browser. This page is built that way.

Examples

Eight examples, one page

Each panel holds a feature with its own state. Use them, and the message log shows every action they handle.

A whole feature in one file, written without the compiler.

A stream that runs only while the clock does. Esc stops it from anywhere.

0

A parent passes a prop to a child feature and handles the event it reports.

  • Apple
  • Apricot
  • Banana
  • Blueberry
  • Cherry
  • Grape
  • Lemon
  • Peach

A form submits its named fields, and a checkbox reports its state.

Keyed rows keep their nodes as the list changes, drawn by a function view.

    0 left

    A query whose args follow the state. The page title follows it too.

    Apple seeds need a cold winter before they sprout.

    A command that replaces a stale request as you type, and cancels on demand.

    effect-ui-tsx

    Effect UI components as a model, a controller and a plain TSX view.

    MIT licensed. Built on Effect UI, which is experimental. This page was rendered ahead of time and hydrated in your browser.