WaterUI: A SwiftUI-inspired cross-platform UI framework for Rust with cross-platform native rendering

I wanted SwiftUI's declarative style and type safety, but for all platforms. So I built WaterUI - a Rust UI framework that gives you the best of both worlds.

Why another UI framework?

I love SwiftUI's approach - declarative, type-safe, with a modern API. But existing cross-platform solutions all have trade-offs:

  • SwiftUI: Apple-only
  • Flutter: Ignores native look-and-feel
  • React Native: JS runtime, not fully type-safe
  • Existing Rust frameworks: Either immediate mode (egui) or missing the reactive programming model I wanted

What makes WaterUI different?

:sparkles: Features:

  • True native rendering - Uses SwiftUI on Apple platforms (yes, even visionOS/watchOS/widgets!), and gtk4 on GTK desktop (more platform is coming soon...)
  • Vue-like fine-grained reactivity - Allows efficient updates without virtual DOM
  • Type-safe from top to bottom - Leverage Rust's type system fully
  • Declarative & reactive - Familiar to SwiftUI/React developers
  • Cross-platform - Supports multiple backends (gtk4 backend and swiftui backend are ready now)

Code Example

use waterui::prelude::*;

pub fn counter() -> impl View {
    let count = Binding::int(0);
    let doubled = count.map(|n| n * 2);
    
    vstack((
        text!("Count: {count}"),
        text!("Doubled: {doubled}")
            .font_size(20)
            .foreground_color(Color::gray()),
        
        hstack((
            button("Increment")
                .action_with(&count,|count| count.increment(1)),
            button("Reset")
                .action_with(&count,|count| count.set(0))
                .foreground_color(Color::red()),
        ))
        .spacing(10),
    ))
    .padding(20)
    .spacing(15)
}

Current Status

The framework is in alpha but actively developed. Core features working:

  • :white_check_mark: Reactive system
  • :white_check_mark: Basic widgets (text, button, stack layouts, etc.)
  • :white_check_mark: SwiftUI backend
  • :white_check_mark: Event handling
  • :construction: More widgets & styling options
  • :construction: Android backends
  • :clipboard: Animation system

GitHub: https://github.com/water-rs/waterui

Tutorial book: https://water-rs.github.io/waterui/

API Reference: https://docs.rs/waterui/

I'd love to hear your thoughts! Especially interested in:

  • Feedback on the API design
  • What widgets/features you'd prioritize
  • Experience with Rust-Swift interop if you've done it

This is my first major open source project in Rust, so any feedback on the code structure would also be appreciated!

3 Likes

Since when does "true" native rendering mean only on one of the supported platforms?

For me, the definition of true native is using the system’s built-in widgets. For example, on a GTK desktop that would mean GTK itself. I actually have a working GTK4 backend in my repo, but it’s still missing a lot of features, so I didn’t mention it earlier. At least it shows that WaterUI can indeed use the native controls of each platform.

That said, my development time is limited, so right now I’m focusing most of my effort on the SwiftUI backend.

1 Like

Because I was indeed inspired a lot by SwiftUI — in fact, my current layout system plan is completely aligned with SwiftUI — I’ve put most of my effort into the SwiftUI backend. WaterUI’s API may still go through many breaking changes since it’s at a very early stage. That’s why I prefer not to spread my efforts across too many backends before finalizing the API design; for now, it’s enough just to ensure the architecture is feasible.

That's nice to see. I'm happy to see that support for other native backends is planned, but I still think it's misleading to claim full native support when only one backend currently supports it.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.