WaterUI
A modern, cross-platform UI framework for Rust that renders to native platform widgets (UIKit/AppKit on Apple, Android View on Android) rather than drawing its own pixels. Build reactive, declarative UIs with Rust's type safety and performance.
Overview
WaterUI combines declarative, component-based architecture with fine-grained reactivity to deliver truly native user interfaces across platforms. Unlike traditional Rust UI frameworks that implement custom rendering, WaterUI translates your Rust view tree into platform-native UI components through an FFI bridge, ensuring your apps look and feel native on every platform.
The framework is built on three core principles:
- Native-first rendering: Your UI components compile to UIKit/AppKit views on iOS/macOS and Android View on Android, delivering authentic native behavior and performance.
- Fine-grained reactivity: Powered by the
namicrate, UI updates are surgical and automatic—only affected components re-render when state changes. - Hot reload: Changes to your Rust code reload instantly in running apps via dynamic library swapping, providing a development experience similar to web frameworks.
WaterUI is ideal for building production mobile apps, cross-platform tools, and native desktop applications where performance and platform integration matter.
Installation
Add WaterUI to your Cargo.toml:
[]
= "0.2"
= "0.2" # Required for FFI export
Enable the graphics feature for GPU rendering capabilities:
[]
= { = "0.2", = ["graphics"] }
Quick Start
The fastest way to experience WaterUI is through the CLI's playground mode, which handles native backend setup automatically:
1. Install the CLI
2. Create and Run a Playground
Your app launches with hot reload enabled. Edit src/lib.rs and watch changes appear instantly.
3. Write Your First View
use *;
use App;
export!;
Core Concepts
The View Trait
Every UI component implements the View trait, which defines how it renders:
use Environment;
Views compose recursively—complex interfaces are built from simple building blocks. The framework handles type erasure, rendering, and updates automatically.
Reactive State
WaterUI uses Binding<T> for mutable state and Computed<T> for derived values. Views automatically update when reactive values change:
use *;
Environment
The Environment provides dependency injection for themes, fonts, and custom services. Values propagate down the view tree without explicit passing:
use App;
use *;
use Environment;
use ;
View Modifiers
WaterUI provides a fluent API for styling and layout through the ViewExt trait:
use *;
use Color;
text
.size
.bold
.foreground
.padding
.background
.on_tap;
Examples
Form with Reactive Bindings
use *;
Interactive Gesture Handling
use *;
use ;
Dynamic List Rendering
use *;
use ;
API Overview
Layout Components
vstack(),hstack(),zstack()- Vertical, horizontal, and depth stacks with configurable spacing and alignmentscroll()- Scrollable container with automatic content overflow handlingspacer()- Flexible space filler for pushing elements apartpadding()- Add insets around views withEdgeInsetsconfigurationFrame- Fixed, minimum, and maximum sizing constraints
Controls
Button- Tappable button with action handler and style variantsTextField- Single-line text input with label and placeholderToggle- Boolean switch control with reactive bindingSlider- Continuous value selector within a rangeStepper- Discrete value adjuster with step incrementPicker- Selection control for choosing from multiple options
Text & Media
Text- Styled text with font, size, weight, and color configurationtext!()macro - Reactive text with format string interpolationstyled()- Rich text with multiple style runsVideoPlayer- Native video playback with controls and event handlinginclude_markdown!()- Compile-time markdown to view conversion
Form Components
#[form]derive macro - Automatic form generation from structsTextField,Toggle,Slider- Form-compatible controls with labels- Automatic field-to-control mapping based on type
Navigation
NavigationView- Hierarchical navigation with title barTabView- Tab-based navigation container.title()modifier - Set navigation bar title
Advanced
Dynamic::watch()- Observe reactive signals and rebuild views on changeAnyView- Type-erased view container for heterogeneous collectionsEnvironment- Dependency injection and context propagationViewExt- Extension trait providing modifier methods for all views
Features
Default Features
The base waterui crate includes layout, controls, text, media, navigation, and form components with native rendering backends.
Optional Features
graphics- Enables GPU rendering with canvas drawing primitives andGpuSurface(requireswaterui-graphics)graphics-minimal- GPU surface only, without canvas (smaller binary size)
Application Entry Point
Every WaterUI app follows this pattern:
use *;
use App;
// Initialize environment (called once at app startup)
// Root view (called on every render)
// Alternative: App with custom environment setup
// Export FFI entry points for native backends
export!;
The waterui_ffi::export!() macro generates C-compatible functions that native backends (Swift/Kotlin) call to render your UI.
Core Architecture
waterui-core- Foundation types:Viewtrait,Environment,AnyView, reactivity primitiveswaterui-ffi- C FFI bridge withexport!()macro for native backend integration
Component Libraries
waterui-layout- Layout containers and geometrywaterui-controls- Buttons, toggles, sliders, text fieldswaterui-text- Text rendering, fonts, and stylingwaterui-form- Form builder with#[form]derive macrowaterui-media- Video/audio playback componentswaterui-navigation- Navigation containers and routingwaterui-graphics- Canvas drawing and GPU rendering (optional)
Tools
waterui-cli- Command-line tool for creating, building, and running apps
CLI Commands
The water CLI provides a complete development workflow:
# Create new project
# Create playground (auto-configured backends)
# Run with hot reload
# Build Rust library for specific target
# Check development environment
# List available devices
Platform Support
- iOS/macOS: Renders to UIKit/AppKit (requires Xcode)
- Android: Renders to Android View (requires Android SDK)
Documentation
- API Reference - Complete API documentation
- Architecture Guide - Technical architecture overview
- Roadmap - Planned features and improvements
Contributing
Contributions are welcome! Please submit pull requests to the dev branch. The main branch is reserved for releases.
Before contributing, check:
- Open issues for feature requests and bugs
- ROADMAP.md for planned work
- CLAUDE.md for development guidelines
License
Licensed under the MIT License. See LICENSE for details.