waterui-controls
Interactive UI controls for WaterUI applications with reactive data binding.
Overview
waterui-controls provides a complete set of form controls and interactive components for WaterUI applications. Each control integrates seamlessly with WaterUI's reactive system through Binding<T> and Computed<T>, enabling automatic UI updates when data changes. Controls render to native platform widgets (UIKit/UIKit/AppKit on Apple, Android Views/Android View on Android), providing a truly native look and feel.
This crate is part of the WaterUI workspace and is re-exported through the main waterui crate's prelude, so most users will access these components via use waterui::prelude::* rather than depending on this crate directly.
Installation
Add to your Cargo.toml:
[]
= "0.1.0"
Or use the main waterui crate which re-exports all controls:
[]
= "0.2"
Quick Start
use *;
use binding;
let name = binding;
let age = binding;
let enabled = binding;
let volume = binding;
vstack
Core Concepts
Reactive Bindings
All controls accept reactive bindings that enable two-way data synchronization:
Binding<T>: Mutable reactive state that updates both when the UI changes and when modified programmaticallyComputed<T>: Read-only derived values that automatically update when dependencies change
let count = binding;
// UI updates when count changes programmatically
count.set;
// count updates when user interacts with stepper
stepper
Layout Behavior
Controls have different layout characteristics:
- Horizontal stretch (
TextField,Slider,Toggle,Stepper): Expand to fill available width - Content-sized (
Button): Size to fit their content - Dynamic (
Progress): Linear style stretches, circular style is content-sized
Components
Button
Triggers actions when clicked. Supports multiple visual styles.
use *;
// Basic button
button.action;
// Styled button
button
.style
.action;
// Link-style button
button
.style
.action;
Available styles: Automatic (default), Plain, Link, Borderless, Bordered, BorderedProminent
Toggle
A switch control for boolean values.
use *;
use binding;
let wifi_enabled = binding;
// Toggle with label
toggle
// Toggle without label (just the switch)
new
Slider
Continuous value selection within a range.
use *;
use binding;
let brightness = binding;
// Basic slider (0.0 to 1.0)
slider
.label
.min_value_label
.max_value_label
// Volume control
let volume = binding;
slider.label
Stepper
Increment or decrement integer values.
use *;
use binding;
let quantity = binding;
// Basic stepper (shows current value)
stepper
// Stepper with label and constraints
stepper
.label
.range
.step
// Custom value formatting
stepper
.value_formatter
TextField
Single-line or multi-line text input.
use *;
use binding;
let email = binding;
let bio = binding;
// Single-line text field
new
.prompt
// With label (convenience function)
field
// Multi-line text field
new
.line_limit
.prompt
Keyboard types: Text (default), Email, URL, Number, PhoneNumber
RichTextEditor
Multi-line text editor with styled text support.
use *;
use binding;
use StyledStr;
let content = binding;
new
.placeholder
.disable_line_limit
Examples
Form with Validation
use *;
use binding;
let username = binding;
let age = binding;
let terms_accepted = binding;
vstack
.padding_with
Settings Panel
use *;
use binding;
let dark_mode = binding;
let notifications = binding;
let volume = binding;
let font_size = binding;
scroll
Reactive Counter
use *;
use binding;
let count = binding;
vstack
Loading States
use *;
use binding;
let progress = binding;
let is_loading = binding;
vstack
API Overview
Controls
Button: Clickable button with customizable styles and actionsToggle: Boolean switch controlSlider: Continuous range selector (f64)Stepper: Discrete numeric adjuster (i32)TextField: Single/multi-line text inputRichTextEditor: Styled text editor
Convenience Functions
button(label): Create a button with a labeltoggle(label, binding): Create a labeled toggleslider(range, binding): Create a sliderstepper(binding): Create a stepperfield(label, binding): Create a labeled text field
Enums
ButtonStyle: Visual styles for buttons (Automatic, Plain, Link, Borderless, Bordered, BorderedProminent)KeyboardType: Keyboard types for text fields (Text, Email, URL, Number, PhoneNumber)
Features
This crate currently has no optional features. All components are included by default.
Platform Notes
All controls render to native platform widgets:
- Apple platforms: UIKit/SwiftUI components (UIButton, UITextField, UISwitch, UISlider, etc.)
- Android: Native Views/Jetpack Compose (Button, TextField, Switch, Slider, etc.)
This ensures controls match the platform's design language and accessibility features automatically.