7 releases
Uses new Rust 2024
| 0.2.4 | Feb 28, 2026 |
|---|---|
| 0.2.3 | Feb 11, 2026 |
| 0.1.0 | Jan 21, 2026 |
| 0.0.1 | Dec 4, 2025 |
#1560 in Graphics APIs
Used in 2 crates
2MB
46K
SLoC
Astrelis UI - Taffy-based UI system with WGPU rendering
This crate provides a flexible UI system built on Taffy layout engine:
- Declarative widget API
- Flexbox and Grid layouts via Taffy
- GPU-accelerated rendering
- Event handling system
- Composable widget tree
Quick Start
let mut ui = UiSystem::new(graphics_context);
ui.build(|root| {
root.container()
.width(800.0)
.height(600.0)
.padding(20.0)
.child(|container| {
container.text("Hello, World!")
.size(24.0)
.color(Color::WHITE)
.build();
container.button("Click Me").build();
container.container().build()
})
.build();
});
// In render loop:
// ui.update(delta_time);
// ui.handle_events(&mut event_batch);
// ui.render(&mut render_pass, viewport_size);
API Conventions
This crate follows consistent method naming conventions:
Mutation Methods
set_*()- Full replacement that may trigger complete rebuild/re-layout- Example:
set_text()replaces text and triggers text shaping
- Example:
update_*()- Incremental update optimized with dirty flags- Example:
update_text()only marks TEXT_SHAPING dirty, skipping layout
- Example:
add_*()- Append to a collection- Example:
add_widget()appends to widget tree
- Example:
Accessor Methods
get_*()- ReturnsOption<&T>for possibly-missing values- Example:
get_widget(id)returnsOption<&Widget>
- Example:
*()(no prefix) - Returns&T, panics if unavailable (use when required)- Example:
widget(id)returns&Widgetor panics
- Example:
try_*()- Fallible operation returningResult- Example:
try_layout()returnsResult<(), LayoutError>
- Example:
has_*()- Boolean check for existence- Example:
has_widget(id)returnsbool
- Example:
Computation Methods
compute_*()- Expensive computation (results often cached)- Example:
compute_layout()runs Taffy layout solver
- Example:
calculate_*()- Mathematical calculation- Example:
calculate_bounds()computes widget bounds
- Example:
Builder Methods
with_*(value)- Builder method returningSelffor chaining- Example:
with_padding(20.0)sets padding and returns builder
- Example:
build()- Finalizes builder and consumes it- Example:
widget.build()adds widget to tree
- Example:
Dependencies
~33–57MB
~891K SLoC