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

MIT license

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
  • update_*() - Incremental update optimized with dirty flags
    • Example: update_text() only marks TEXT_SHAPING dirty, skipping layout
  • add_*() - Append to a collection
    • Example: add_widget() appends to widget tree

Accessor Methods

  • get_*() - Returns Option<&T> for possibly-missing values
    • Example: get_widget(id) returns Option<&Widget>
  • *() (no prefix) - Returns &T, panics if unavailable (use when required)
    • Example: widget(id) returns &Widget or panics
  • try_*() - Fallible operation returning Result
    • Example: try_layout() returns Result<(), LayoutError>
  • has_*() - Boolean check for existence
    • Example: has_widget(id) returns bool

Computation Methods

  • compute_*() - Expensive computation (results often cached)
    • Example: compute_layout() runs Taffy layout solver
  • calculate_*() - Mathematical calculation
    • Example: calculate_bounds() computes widget bounds

Builder Methods

  • with_*(value) - Builder method returning Self for chaining
    • Example: with_padding(20.0) sets padding and returns builder
  • build() - Finalizes builder and consumes it
    • Example: widget.build() adds widget to tree

Dependencies

~33–57MB
~891K SLoC