Allui (read as: Alloy)
A SwiftUI-inspired UI framework for Rust, built on GPUI and gpui-component.
Allui brings SwiftUI's declarative, composable API to Rust desktop applications. If you know SwiftUI, you already know Allui. If you know Jetpack Compose, it’s close enough.
Why Allui?
The Problem: Building desktop UIs in Rust typically means either low-level graphics programming or fighting with paradigms that don't fit the language. SwiftUI proved that declarative UI can be both powerful and ergonomic, but it's locked to Apple platforms.
The Solution: Allui provides SwiftUI's mental model and API patterns on top of GPUI (Zed editor's GPU-accelerated UI framework). You get:
- Familiar patterns - VStack, HStack, ZStack, modifiers, and component composition work like SwiftUI
- True modifier semantics -
.padding().background()differs from.background().padding(), just like SwiftUI - Native performance - GPU-accelerated rendering via GPUI
- Cross-platform - Runs wherever GPUI runs (macOS, Linux, Windows)
Architecture
┌─────────────────────────────────────────────────────────────┐
│ Your Application │
├─────────────────────────────────────────────────────────────┤
│ Allui │
│ ┌─────────────────────┐ ┌────────────────────────────┐ │
│ │ Layout Primitives │ │ Components │ │
│ │ ───────────────── │ │ ──────────────────── │ │
│ │ VStack, HStack │ │ Text, Button, Toggle │ │
│ │ ZStack, Spacer │ │ TextField, Slider │ │
│ │ ScrollView, List │ │ Picker, ProgressView │ │
│ │ LazyVStack/HStack │ │ Image, Label, Link │ │
│ │ Grid, LazyVGrid │ │ │ │
│ │ LazyHGrid │ │ │ │
│ └─────────────────────┘ └────────────────────────────┘ │
│ ┌─────────────────────┐ ┌────────────────────────────┐ │
│ │ Modifier System │ │ Control Flow │ │
│ │ ───────────────── │ │ ──────────────────── │ │
│ │ padding, frame │ │ ForEach, If, IfLet │ │
│ │ background, border │ │ Section, GridRow │ │
│ │ corner_radius │ │ GridItem │ │
│ │ shadow, opacity │ │ │ │
│ └─────────────────────┘ └────────────────────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ gpui-component │
│ (Stateful widgets: Switch, Input, etc.) │
├─────────────────────────────────────────────────────────────┤
│ GPUI │
│ (GPU-accelerated rendering engine) │
└─────────────────────────────────────────────────────────────┘
Quick Start
Add Allui to your Cargo.toml:
[]
= "0.1"
= "0.2"
= "0.5"
Create a simple view:
use ;
use *;
Core Concepts
Layout Stacks
Allui uses the same stack-based layout system as SwiftUI:
// Vertical stack - centers horizontally by default
new
.spacing
.alignment
.child
.child
// Horizontal stack - centers vertically by default
new
.spacing
.child
.child
.child
.child
// Overlay stack - centers in both axes
new
.child
.child
Modifier Chain
Modifiers wrap views in container elements. Order matters:
// Padding INSIDE the background (blue box with internal padding)
new
.padding
.background
// Padding OUTSIDE the background (blue box with external spacing)
new
.background
.padding
Available modifiers:
| Category | Modifiers |
|---|---|
| Layout | padding, frame, frame_size, frame_width, frame_height, fixed_size, aspect_ratio |
| Visual | background, foreground_color, corner_radius, border, shadow, opacity |
| Behavior | hidden, disabled, on_tap_gesture |
Scrolling & Lists
// Basic scroll view
new
.axes
.child
// iOS-style grouped list
new
.list_style
.child
.child
Control Flow
// Iterate over collections
new
.children
// Conditional rendering
new
.then
.otherwise
// Optional content
new
Virtualized Lists
For large datasets, use lazy stacks that only render visible items:
Grid Layouts
Allui provides both static and lazy grid layouts:
// Static Grid - auto-sizing columns based on content
new
.horizontal_spacing
.vertical_spacing
.child
.child
// LazyVGrid - vertically-scrolling grid with fixed columns
let columns = vec!;
new
.rows
.spacing
.item_count
.render_item
.build
Components
Display Components
| Component | Description |
|---|---|
Text |
Styled text with font and color options |
Label |
Icon + text combination |
Image |
Display images from files, URLs, or system icons |
Divider |
Visual separator line |
ProgressView |
Spinner or progress bar |
Link |
Tappable text that triggers actions |
Input Components
| Component | Description |
|---|---|
Button |
Tappable button with multiple styles |
Toggle |
Boolean switch |
TextField |
Single-line text input |
SecureField |
Password input (masked) |
TextEditor |
Multi-line text input |
Slider |
Range value selection |
Stepper |
Increment/decrement control |
Picker |
Selection from options |
Layout Components
| Component | Description |
|---|---|
VStack |
Vertical stack layout |
HStack |
Horizontal stack layout |
ZStack |
Overlay/layered layout |
Spacer |
Flexible space |
ScrollView |
Scrollable container (vertical, horizontal, or both) |
List |
iOS-style sectioned list |
Grid |
Static 2D table layout with auto-sizing columns |
LazyVStack |
Virtualized vertical list |
LazyHStack |
Virtualized horizontal list |
LazyVGrid |
Virtualized vertical grid with fixed columns |
LazyHGrid |
Virtualized horizontal grid with fixed rows |
Examples
Run the interactive storybook to see all components:
Important Notes
Initialization
Before using any gpui-component widgets (Toggle, TextField, etc.), initialize:
State Management
Allui components are presentational. State lives in your GPUI view:
License
MIT License - see LICENSE.md for details.