EguiWidget - Zero-Cost UI Generation for egui
A procedural macro that automatically generates egui UI from Rust structs using attribute annotations. Zero runtime overhead — everything is generated at compile time.
🚀 Quick Start
Add #[derive(EguiWidget)] to your configuration struct and instantly generate a full egui UI!
Example Struct
use EguiWidget;
Use in Your App
🧩 Supported UI Controls
| 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" |
📋 Configuration Fields
| 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) |
🛠️ Installation
Add to your Cargo.toml:
[]
= "0.1.0"
📦 Suggested Cargo.toml
If you're using this macro in your app:
[]
= "my-egui-app"
= "0.1.0"
= "2021"
[]
= "^0.31"
= "^0.31" # For desktop apps
= "0.1.0" # Local path or from crates.io
📎 Screenshot

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)吗?我可以立即提供完整项目结构。