
EFx
EFx β Rust π¦ XML Template Engine for egui-based frameworks: eframe, bevy_egui, egui-winit, egui-miniquad.
efx! is a proc-macro for writing tiny XML-like UI snippets in eframe/egui. It converts short tags into egui calls.
You can embed arbitrary Rust expressions inside braces ({...}).
Install & import
Requires egui (the project currently uses egui 0.32). Add to Cargo.toml:
[]
= "0.5"
= "0.32" # or egui-based framework
Inside this repo just import the macro:
use efx; // the macro
Documentation
You can see on web page https://docs.rs/efx/latest/efx/ or in files:
Expression interpolation {...}
Inside tag content you can insert any Rust expression that implements Display:
let a = 2;
let b = 3;
efx!;
Escaping braces
To print { or }, use double braces (same as format!):
efx!;
Errors & diagnostics
At compile time the macro parses your snippet; at runtime it shows readable diagnostics via ui.Label(...) when input is invalid:
-
Unknown tag Output:
Unknown tag: <TagName> -
Mismatched open/close tags Output:
Mismatched tags: <open> and </close> -
Interpolation count mismatch Happens if the parser found e.g. two
{expr}parts but after processing the text thereβs a different number of{}placeholders. Make the counts match.
Current limitations
- Case-sensitive tag names.
- Interpolated expressions must implement
Display.
Roadmap & RFCs
TL;DR. EFx is a minimalist XML DSL on top of egui that compiles to plain ui.* calls.
The next three releases focus on expressiveness and first-class examples across popular egui runtimes:
- 0.5 β Attributes & core tags: type-checked attributes,
Heading,Hyperlink,Image,TextField,Grid, plusWindow/CentralPanel/SidePanel. Diagnostics & examples. - 0.6 β Components & events: reusable components/slots, event sugar (
onClick, etc.), classes/presets, Bevy examples. - 0.7 β Themes & layouts: lightweight style sheets, extended containers (
Tabs/Tablebehindextras), perf & polish.
This plan is incremental and non-breaking; new features are opt-in. Priorities may change based on community feedback.
π Full RFC: EFX-0001 β Roadmap 0.5β0.7
π RFC index: RFC/README.md
Supported egui runtimes
EFx renders into any runtime that provides &mut egui::Ui. We officially build examples for the following targets:
Tier-1
eframe(native + wasm)bevy_egui(native)- raw
winit+wgpu(viaegui-winit+egui-wgpu). Wgpu - a cross-platform, safe, pure-rust graphics API. It runs natively on Vulkan, Metal, D3D12, and OpenGL; and on top of WebGL2 and WebGPU on wasm. Follows WebGPU specification. With async/await API.
Tier-2 (compatible today; examples later / community support)
egui-miniquad(formacroquad/miniquadoverlays) - Relatively minimalistic API well suited for small to medium graphics projects. Supports multiple backends, including browser target.egui_sdl2_*backendsegui_glow/tao(lower-level backends)
Quickstart (pick one)
A) eframe
# Cargo.toml
[]
= "0.5"
= "0.32"
use egui;
use efx;
default.show;
B) Bevy + bevy_egui
# Cargo.toml
[]
= "0.5"
= "0.16"
= "0.36" # re-exports `egui`
use ;
use efx;
new.show;
Tip: import
eguiviause bevy_egui::egui as egui;to avoid version mismatches.
C) Raw winit + wgpu
# Cargo.toml
[]
= "0.5"
= "0.32"
= "0.32"
= "0.32"
= "0.30"
= "26.0"
Use the example in examples/winit_wgpu_min.rs as a starting point.
Contributing
- Start with the roadmap RFC: EFX-0001.
- You can write me with your ideas on mail@zhukmax.com.
- Open issues are grouped by milestones 0.5 / 0.6 / 0.7.
- PRs that change behavior should reference the relevant RFC section.
- Looking for help with: Bevy example(s), raw
winit+wgpuexample, attribute codegen & compile-fail tests,TextFielddocs.
Changelog
See in file Changelog.md
Licence
The MIT License. Please see License File for more information.