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

⚓ Rust    📅 2025-09-07    👤 surdeus    👁️ 1      

surdeus

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!

5 posts - 2 participants

Read full topic

🏷️ Rust_feed