---
title: "oneui"
url: https://recursiveai.org/oneui/
description: "A UI component model for .NET. Components are an HTML template, an optional CSS file and a C# class, compiled and checked at build time by a source generator in the package. A C# builder adds CSS-model styling, flexbox layout, display-list painting, input routing and themed controls. MIT or Apache-2.0. 1.0.0."
---

# 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](https://github.com/recursive-ai-oss/oneui-csharp/commit/8194377fae41666c406788bac45243a33db9e5ee), with no dependency on the game engine.

```sh
dotnet add package RecursiveAI.OneUI --version 1.0.0
```

- [Getting started](https://recursiveai.org/oneui/docs/getting-started/)
- [Docs](https://recursiveai.org/oneui/docs/)
- [GitHub](https://github.com/recursive-ai-oss/oneui-csharp)
- [NuGet](https://www.nuget.org/packages/RecursiveAI.OneUI)

## 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.

[The template syntax](https://recursiveai.org/oneui/docs/markup/)

*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++;
}
```

*Program.cs · OneUI 1.0.0 · .NET 10*

```
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}\"");
```

*Output*

```
<button class="btn" data-oui-fc0f33c3>Clicked 2 times</button>
SetText node 3: "Clicked 2 times"
```

### 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](https://recursiveai.org/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](https://recursiveai.org/oneapp/).
- **.NET**: .NET 10, C#. “NativeAOT- and trim-compatible and uses no reflection.” MIT or Apache-2.0.

## Go further

- [GitHub](https://github.com/recursive-ai-oss/oneui-csharp)
- [NuGet](https://www.nuget.org/packages/RecursiveAI.OneUI)
- [Getting started](https://recursiveai.org/oneui/docs/getting-started/)
- [All docs](https://recursiveai.org/oneui/docs/)
- [Diagnostics](https://recursiveai.org/oneui/docs/diagnostics/)
- [Changelog](https://recursiveai.org/oneui/docs/changelog/)
