libyue 的 MoonBit 封装:统一跨平台 GUI API,平台差异由库内部吸收,消费方无感
Thanks to Cheng Zhao (zcbenz) and his Yue framework, and to MoonBit. As it happens, both of these programming tools carry the character for "moon" — and I have grown fond of them both. About me and libyue

@yue.theme_apply({ ..@yue.theme_from_system(), primary: "#1E4FA3" })let window = @yue.mount_window(
[
@yue.label("Hello, MoonBit + libyue!", style=[("margin", 20.0)]),
@yue.button("Quit", on_click=fn() { @yue.quit() }),
],
title="Hello", size=Some((420.0, 160.0)), center=true, on_close=fn(_w) { @yue.quit() },
)let clicks = @yue.Signal::new(0)
let text = @yue.Signal::computed(fn() { "Clicked \{clicks.get()} times" }) // dependencies auto-collected
@yue.button("Click me", on_click=fn() { clicks.update(fn(n) { n + 1 }) }),
@yue.bind(text, fn(s) { s }),match @yue.Tray::new("icon.png") {
Ok(t) => t.on_click(fn() { window.show() })
Err(_e) => ()
}
let n = @yue.Notification::new()
n.set_title("Build finished")
n.show()moon run examples/sysmonitor55 native widgets fully bound · 57 themed self-drawn components · wrapper overhead startup on par with C++, memory +0.8MB · three-platform CI · published on mooncakes
Upgrading to 0.5.0: the Browser binding moved to a standalone package. Add "NoahLiu/moonbit-libyue/yue/browser" to your imports (@yue.Browser → @browser.Browser, API unchanged). Apps that don't import it are no longer linked against WebKit/WebView2.
| Document | Content |
|---|---|
| tutorial.md | Five-minute quick start: from moon new to a running window, avoiding the three newcomer pitfalls |
| declarative.md | Declarative Node/mount render tree + Store reactive bindings |
| layout.md | Layout style key quick reference: all style keys + common-combination examples |
| components-ui.md | Themed component library quick reference: per-API signatures + parameter tables, including theme customization / light-dark switching |
| components.md | Widget API quick reference: both the classic setter and X::make props styles |
| Troubleshooting & topics | Platform adaptation notes · Linux tray · native-layer relink (three standalone documents) |
Install
Download ziplibyue 的 MoonBit 封装:统一跨平台 GUI API,平台差异由库内部吸收,消费方无感