Recursive AI

RecursiveAI.OneUI

All oneui docs

A UI component model for .NET. Components are an HTML template, an optional CSS file and a C# class; a source generator that ships in the package turns each one into create and update code and checks every binding, event, element and CSS property at build time. A second front end builds the same kind of tree from C# calls and adds CSS-model styling, flexbox layout, painting to a display list, input routing, tweens and a kit of themed controls (buttons, text input, dropdown, list, table, tabs, scroll view, slider, dialog).

The package depends only on .NET and RecursiveAI.OneFont. It is NativeAOT- and trim-compatible and uses no reflection.

Markup components

A component is a template, an optional stylesheet and a partial class with the same name:

Counter.html

HTML
<button class="btn" on:click="Increment">Clicked {Count} times</button>

Counter.cs

C#
using OneUI.Components;
 
public partial class Counter
{
    [State]
    public partial int Count { get; set; }
 
    private void Increment() => Count++;
}

Clicking the button changes Count; the one text node that reads it is the only thing that is rewritten. Unknown names, bad bindings and CSS the engine cannot render are build errors with a stable OUI id: see docs/diagnostics.md for the list and docs/markup.md for the template syntax.

A component does not draw. It writes mutations (create a node, set an attribute, insert, listen) as a change set to a document that implements IChangeSink. This package has the reference document, an in-memory DOM with selector queries, click and key helpers and a readable HTML dump, which is what tests use. The native window backend and the browser backend (WebAssembly, with components registered as custom elements) are provided by RecursiveAI.OneApp.

The C# builder

The other front end is OneUI.Element, a retained tree you build and style in code. UiTree styles it, lays it out, handles input and focus, and produces a DisplayList for a host to paint.

C#
var tree = new UiTree();
tree.SetViewport(640, 360, 1);
var kit = new KitHost(tree);
tree.Root.Add(kit.AttachTo(Ui.Column(
    Ui.Label("Hello"),
    UiKit.Button("Count", () => log("clicked"), "count")).Padding(16).Gap(8)));
var list = tree.Frame(); // the display list: what to paint

Contents

  • OneUI.Components: components, state, the change-set protocol, the reference document (OneUI.Components.Reference).
  • OneUI: Element, Ui, UiTree, styles, layout, display list.
  • OneUI.Kit: UiKit controls, KitHost, theme tokens, text editing, contrast checks.
  • OneUI.Tweens: easing and tweens.

Repository layout

  • src/OneUI: the library. src/OneUI.Generators: the markup compiler, shipped inside the package as an analyzer.
  • docs/: markup, change sets, diagnostics, CSS support.
  • samples/Todo: an app built from markup and run against the reference document.
  • tests/OneUI.Tests, tests/OneUI.Kit.Tests, tests/OneUI.Components.Tests, tests/OneUI.Generators.Tests: xUnit v3 tests. Layout is checked against boxes measured in headless Chrome (testdata/ui-layout, regenerated with tools/ui-layout-reference/generate.py).
  • tests/OneUI.AotSmoke: a NativeAOT app that mounts a component, builds a screen, clicks and types.
  • tools/css-table: regenerates the table of CSS properties the compiler accepts.

Build and test

dotnet build OneUI.slnx
dotnet test --solution OneUI.slnx
dotnet test --project tests/OneUI.Components.Tests

The test projects use the Microsoft.Testing.Platform runner, selected in global.json; run dotnet test from inside the repository so that file is found. Set ONEUI_ARTIFACTS to choose where build output goes; the default is artifacts/.

Licensed under MIT OR Apache-2.0.