# StateUI — a Swift declarative UI layer for .NET MAUI

**URL:** <https://forums.swift.org/t/stateui-a-swift-declarative-ui-layer-for-net-maui/89205>\
**Category:** Community Showcase\
**Created:** [August 26, 2026, 2:12pm UTC](https://forums.swift.org/t/stateui-a-swift-declarative-ui-layer-for-net-maui/89205 "2026-08-26T14:12:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![idexus](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/idexus/32/46400_2.png) [@idexus](https://forums.swift.org/u/idexus)\
**Post date:** [August 26, 2026, 2:12pm UTC](https://forums.swift.org/t/stateui-a-swift-declarative-ui-layer-for-net-maui/89205/1 "2026-08-26T14:12:20Z")

</div>

Hi everyone,

I've been working on StateUI:

[https://github.com/idexus/StateUI](https://github.com/idexus/StateUI)

It started as an experiment — how far could Swift go as the application and UI language outside the Apple stack, without building yet another cross-platform widget toolkit? Swift does the declarative UI, the state and the reconciliation; .NET MAUI provides the controls and the platform layer on iOS, Android, Windows and Mac Catalyst.

A complete application - a window, two tabs, and the state that moves them:

```swift
enum Tab: Hashable, CaseIterable {
    case counter
    case list
}

struct GalleryApp: Application {
    func createWindow() -> Window { MainWindow() }
}

struct MainWindow: Window {
    @State private var tab: Tab = .counter

    var title: String? { "StateUI" }

    var content: Page {
        TabbedPage(Tab.allCases) { which in
            switch which {
            case .counter: CounterPage(tab: $tab)
            case .list: ListPage()
            }
        }
        .selection($tab)
    }
}

struct CounterPage: ContentPage {
    @Binding var tab: Tab

    @State private var counter = 0

    var title: String? { "Counter" }

    var content: Element {
        VStack {
            Label("Count: \(counter)")
                .fontSize(20)
                .horizontalTextAlignment(.center)

            Button("Increment")
                .cornerRadius(8)
                .onClicked { counter += 1 }

            Button("Go to the list")
                .onClicked { tab = .list }
        }
        .spacing(20)
        .padding(24)
    }
}

struct ListPage: ContentPage {
    var title: String? { "List" }

    var content: Element {
        CollectionView(1...100) { number in
            Label("Row \(number)")
                .fontSize(16)
                .padding(16, 12)
        }
        .itemSize(44)
    }
}

```

Swift keeps the rendered tree, tracks which state each view read, and reconciles. What crosses to C# is a sparse binary patch — only what changed — and the MAUI side applies it to the native controls already on screen.

It is at 0.2.0 — every control MAUI 10 draws, a gallery app that exercises each one, and 660 Swift plus 512 C# tests. The API still moves between versions, and the `0.` in front is meant literally.

I'm curious what people make of the broader idea: Swift as the declarative layer over an existing native UI runtime, rather than a new widget stack underneath it.

 ![Screenshot 2026-08-26 at 16.26.17](https://global.discourse-cdn.com/swift/original/3X/d/9/d905f6e8d36ee94108d127ed9cd611355ce2e736.jpeg)  
 ![Screenshot 2026-08-26 at 16.26.32](https://global.discourse-cdn.com/swift/original/3X/7/a/7a0eac8c2a050a9548a1f8c0ab3d52689e9c5680.jpeg)

---

<div class="post-metadata">

**Author:** ![idexus](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/idexus/32/46400_2.png) [@idexus](https://forums.swift.org/u/idexus)\
**Post date:** [August 29, 2026, 7:35am UTC](https://forums.swift.org/t/stateui-a-swift-declarative-ui-layer-for-net-maui/89205/2 "2026-08-29T07:35:35Z")

</div>

**Small update — Linux works now.** Same Swift tree on iOS, Android, macOS, Windows and Linux; on Linux it's real GTK4 widgets, through MAUI's (preview) GTK4 backend.

The gallery on Ubuntu 24.04, GTK4

 ![gallery-linux2](https://global.discourse-cdn.com/swift/original/3X/b/a/ba594f9f0d0a2d86df28d71d346315b33ef6cf93.jpeg)
