Crates.io | rlvgl-ui |
lib.rs | rlvgl-ui |
version | 0.1.2 |
created_at | 2025-08-11 19:46:06.152308+00 |
updated_at | 2025-08-27 07:08:01.285746+00 |
description | High-level UI components and theming for rlvgl. |
homepage | |
repository | |
max_upload_size | |
id | 1790757 |
size | 62,137 |
Package: rlvgl-ui
(Copy-paste this single file into ui/README.md
or anywhere you like.)
rlvgl-ui is a second-layer crate that sits atop the low-level rlvgl
bindings
(and therefore the C-based LVGL engine).
It offers a Chakra / React-inspired API—themes, tokens, fluent styles, and composable components—without sacrificing the raw speed and tiny footprint that make LVGL the go-to GUI for micro-controllers and small MPUs.
┌─────────────┐ Your app (Button::new().on_click(save)) ├─────────────┤ rlvgl-ui (Theme, Style, VStack …) ├─────────────┤ rlvgl (safe Rust LVGL wrappers) ├─────────────┤ lvgl-sys (raw C FFI) └─────────────┘
Benefit | Details |
---|---|
Familiarity | React / Chakra devs feel at home. |
Productivity | Style::new().bg(...) replaces dozens of lv_obj_set_style_*() calls. |
Interoperable | 100 % compatible with LVGL themes & styles; C and Rust can mix. |
Tiny Footprint | Adds ergonomics, not a JS engine or GC. |
Cargo.toml
[dependencies]
rlvgl = "0.2"
rlvgl-ui = { path = "ui" } # local path while hacking
Minimal code
use rlvgl_ui::{Theme, Style, Button, VStack};
fn ui() {
let theme = Theme::material_light();
theme.apply_global(); // push tokens to LVGL
VStack::new()
.spacing(theme.spacing.md)
.child(
Button::new("Save")
.icon("save") // built-in icon font
.style(
Style::new()
.bg(theme.colors.primary)
.radius(theme.radii.md)
)
.on_click(|| { println!("Saved!"); })
)
.mount(lv_scr_act());
}
Build & run
Desktop simulator:
cargo run --example demo -p rlvgl-ui
MCU target (e.g. STM32-H723):
cargo build --release --target thumbv7em-none-eabihf -p rlvgl-ui
Deterministic instructions for any LLM or tool generating or refactoring code
inside ui/.
Modify files only within ui/ unless explicitly instructed.
Preserve public API signatures unless version number is bumped.
All generated styles must compile to valid lv_style_t
data.
Token namespaces are fixed: spacing, colors, radii, fonts.
Maximum source-line length: 100 columns.
MIT-license header: MIT / Apache-2.0.
use rlvgl_ui::{Theme, Style, Button, VStack};
pub fn build() {
let theme = Theme::material_light();
theme.apply_global();
VStack::new()
.spacing(theme.spacing.md)
.child(
Button::new("Save")
.icon("save")
.style(
Style::new()
.bg(theme.colors.primary)
.radius(theme.radii.md)
)
.on_click(|| { println!("Saved!"); })
)
.mount(lv_scr_act());
}
MIT-licensed: MIT.
“Tiny screens deserve great UX, too.”