oneui
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).
It started as onegame’s UI layer (OneGame.UI, its kit and tweens) and was moved into its own package, with no dependency on the game engine.
A quick look
A component is a template and a partial class with the same name. Clicking the button changes Count, and the one text node that reads it is the only thing rewritten.
Here it runs on the reference document, the in-memory DOM in the package that tests use. A misspelled name or a CSS property the renderer can’t draw is a build error with an OUI id.
<button class="btn" on:click="Increment">Clicked {Count} times</button>
using OneUI.Components; public partial class Counter { [State] public partial int Count { get; set; } private void Increment() => Count++; }
using OneUI.Components; using OneUI.Components.Reference; var dom = new ReferenceDocument(); var ctx = new UiContext(dom); dom.Context = ctx; ctx.Mount(new Counter()); dom.Click(".btn"); dom.Click(".btn"); Console.WriteLine(dom.ToHtml()); foreach (Change c in dom.Commits[^1].Changes) Console.WriteLine($"{c.Kind} node {c.Node}: \"{c.Value}\"");
<button class="btn" data-oui-fc0f33c3>Clicked 2 times</button> SetText node 3: "Clicked 2 times"
What it does
Markup components
Text and attribute bindings, events, two-way binding on inputs, conditionals, keyed lists, child components with parameters and slots, element references and focus, inline SVG, and a scoped stylesheet per component.
Checked at build time
Unknown names, bad bindings and CSS the engine can’t render are build errors with a stable OUI id, at the line and column in the .html or .css file.
Change sets
A component doesn’t draw. It writes its mutations (create a node, set an attribute, insert, listen) as one change set per batch to a document that implements IChangeSink.
The C# builder
Element is a retained tree you build and style in code. UiTree styles it, lays it out with flexbox, handles input and focus, and produces a display list for a host to paint.
The package
- Package
RecursiveAI.OneUI, version 1.0.0. The markup compiler ships inside it as an analyzer. - Dependencies
“The package depends only on .NET and RecursiveAI.OneFont.” onefont is our font and text-shaping library.
- Documents
The 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 in oneapp.
- .NET
.NET 10, C#. “NativeAOT- and trim-compatible and uses no reflection.” MIT or Apache-2.0.