| Crates.io | orzegui |
| lib.rs | orzegui |
| version | 0.1.0 |
| created_at | 2025-10-11 02:37:30.832765+00 |
| updated_at | 2025-10-11 02:37:30.832765+00 |
| description | A proc-macro to automatically generate egui UI from struct fields |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1877770 |
| size | 132,437 |
A procedural macro that automatically generates egui UI from Rust structs using attribute annotations. Zero runtime overhead — everything is generated at compile time.
Add #[derive(EguiWidget)] to your configuration struct and instantly generate a full egui UI!
use orz_egui::EguiWidget;
#[derive(EguiWidget, Default)]
struct MySettings {
author: String,
#[egui(text = "Email", width = 150.0, min_width = 100.0)]
email: String,
#[egui(text = "NAME")]
name: String,
#[egui(radio, choices = "Red,Green,Blue")]
color: String,
#[egui(checks, choices = "Red,Green,Blue")]
lover_color: Vec<String>,
#[egui(text = "Ok")]
ok: bool,
#[egui(text = "SPEED")]
speed: f32,
}
fn main(){
let options = eframe::NativeOptions::default();
let mut settings = MySettings::default();
eframe::run_simple_native("My egui App", options, move |ctx, _frame| {
egui::Window::new("Settings").show(ctx, |ui| {
settings.ui(ui);
});
});
}
| Field Type | Control | Attributes |
|---|---|---|
String |
Text Input | text="Label", width, min_width |
f32 |
Drag Value | text="Label", speed (optional) |
bool |
Checkbox | text="Label" |
String + radio |
Radio Buttons | choices="A,B,C" |
Vec<String> + checks |
Checkboxes | choices="A,B,C" |
| Field | Type | Description |
|---|---|---|
author |
String |
Author name |
email |
String |
Email address with fixed input width |
name |
String |
Name, displayed with label "NAME" |
color |
String |
Primary color selection (Red/Green/Blue) |
lover_color |
Vec<String> |
Multi-select favorite colors |
ok |
bool |
Toggle switch |
speed |
f32 |
Speed adjustment (0.0 ~ 1.0) |
Add to your Cargo.toml:
[dependencies]
orzegui = "0.1.0"
Cargo.tomlIf you're using this macro in your app:
[package]
name = "my-egui-app"
version = "0.1.0"
edition = "2021"
[dependencies]
egui = "^0.31"
eframe = "^0.31" # For desktop apps
orzegui = "0.1.0" # Local path or from crates.io

Tip: Save your actual UI screenshot as
screenshot.png.
Generated by EguiWidget • 2025
---
### ✅ 英文版 `Cargo.toml` (for the macro crate)
```toml
[package]
name = "egui-widget"
version = "0.1.0"
description = "A proc-macro to automatically generate egui UI from struct fields"
license = "MIT"
authors = ["Your Name <your.email@example.com>"]
repository = "https://github.com/yourname/egui-widget"
documentation = "https://docs.rs/egui-widget"
keywords = ["egui", "gui", "procedural-macro", "ui", "derive"]
categories = ["gui", "development-tools::procedural-macros"]
edition = "2021"
readme = "README.md"
[lib]
proc-macro = true
[dependencies]
syn = { version = "2.0", features = ["full"] }
quote = "1.0"
proc-macro2 = "1.0"
[dev-dependencies]
eframe = "0.22"
✅ 优点:
ComboBox, Enum 等)需要我生成一个 examples/demo.rs 或打包为模板仓库(template repo)吗?我可以立即提供完整项目结构。