mirui
A lightweight, no_std ECS-driven UI framework for embedded, desktop, and WebAssembly.
Features
- ECS architecture — entities, components, systems, resources, queries
no_std+alloc— runs on bare-metal MCUs (ESP32-C3, STM32) with a global allocator- Declarative DSL —
ui!macro powered by xrune - Flexbox + absolute positioning — familiar layout model
- HiDPI support — automatic scale factor handling
- Dirty-flag partial refresh — only re-renders changed regions (160fps on ESP32-C3)
- ScrollView — inertia, elastic bounce, scroll chaining, spring resistance
- Components — Button, Checkbox, ProgressBar, Image, ScrollView
- Pluggable backends — SDL2 (desktop), FramebufBackend (embedded)
Quick Start
[]
= "0.1"
= "0.1"
use App;
use SdlBackend;
use *;
use Color;
use WidgetBuilder;
use ui;
DSL Syntax
ui!
Supported Attributes
| Attribute | Type | Description |
|---|---|---|
bg_color |
Color |
Background color |
text |
&str |
Text content |
text_color |
Color |
Text color |
border_radius |
u16 |
Corner radius |
border_color |
Color |
Border color |
width / height |
u16 |
Fixed size |
grow |
f32 |
Flex grow factor |
direction |
FlexDirection |
Row / Column |
justify |
JustifyContent |
Main axis alignment |
align |
AlignItems |
Cross axis alignment |
padding |
Padding |
Inner padding |
position |
Position |
Flex / Absolute |
left / top |
i32 |
Absolute position |
image |
Image |
Image component |
ECS
// Spawn entities
let e = world.spawn;
world.insert;
// Query
let mut buf = Vecnew;
world....collect_into;
for e in &buf
// Resources (global singletons)
world.insert_resource;
let dt = world..unwrap.0;
// Systems
app.add_system;
app.systems.add_fn;
ScrollView
ui! ;
Features: drag scrolling, inertia, elastic bounce with spring resistance, scroll chaining for nested scroll views.
Performance
Tested on ESP32-C3 (RISC-V 160MHz, no FPU) + ST7735S 128×128 SPI display:
| Mode | FPS | Notes |
|---|---|---|
| Full-screen refresh | 60 | SPI 26MHz bottleneck |
| Partial refresh (dirty rect) | 160 | Only changed regions transmitted |
| Binary size (.text) | ~36KB | mirui + app + esp-hal |
Hardware Examples
See mirui-examples for ESP32-C3 demos including three-body physics simulation with partial refresh.
License
MIT