Egui Probe
Effortlessly create UI widgets to display and modify value types using a derive macro with rich customization via attributes. This library is exclusively for the egui UI framework.
Features
- 🪄 Derive Macro: Automatically generate UI widgets for your types.
- 🎨 Rich Customization: Customize the generated widgets using attributes.
- 🚀 Seamless Integration: Designed to work seamlessly with egui.
Getting Started
Add egui_probe to your Cargo.toml:
[]
= "0.5.2"
Usage
Derive EguiProbe for your types.
Use attributes to customize the UI:
Simple Example
And this is what you get:

Advanced Example
;
] u32);
And this is what you get:

Attributes
Type Attributes
-
#[egui_probe(rename_all = kebab-case)]: Changes default name of all fields into specified case. Available cases are:snake_casecamelCasekebab-casePascalCaseSCREAMING_SNAKE_CASEorUPPER_SNAKE_CASETrain-Case
-
#[egui_probe(where TypeA: TraitB)]: Adds where clause to theEguiProbeimplementation. Predicates follow Rust syntax. -
#[egui_probe(transparent)]: Renders entire type as its only field. Won't compile if the type doesn't have exactly one non-skipped field. -
#[egui_probe(tags kind)]: Controls how enum variants are rendered. If kind iscombobox, a combobox is used to select the variant. If kind isinlined, the variant is rendered inline using radio buttons.
Variant Attributes
#[egui_probe(name = "custom name")]: Rename the variant in the UI.#[egui_probe(transparent)]: Renders the variant as its only field. Won't compile if the variant doesn't have exactly one non-skipped field.
Field Attributes
-
#[egui_probe(skip)]: Skip the field in the UI. No other attributes should be used with this attribute. -
#[egui_probe(name = "custom name")]: Rename the field in the UI. -
#[egui_probe(with probe_fn)]: Render a filed using specified probe function with signaturefn(&mut FieldType, &mut Ui, &egui_probe::Style) -> egui::Response. Node thatprobe_fncan be an expression, so closure can be used. -
#[egui_probe(as probe_fn)]: Render a filed using specified probe function with signaturefn(&mut FieldType) -> impl EguiProbe. i.e. wrapping the field into type that implementsEguiProbe. -
#[egui_probe(range = 22..=55)]: Specify a range for numeric values. Works on optionals too. -
#[egui_probe(multiline)]: Render a string as a multiline text box. Field must be of typeStringor&str. Or an option of those. -
#[egui_probe(toggle_switch)]: Render a boolean as a toggle switch. Field must be of typeboolor an optional ofbool. -
#[egui_probe(frozen)]: Renders a collection without controls to add or remove elements. -
#[egui_probe(rgb)]: Render opaque color picker in RGB space. Field must be of typeegui::Color32,egui::Rgba,[u8; 3]or[f32; 3]. -
#[egui_probe(rgba)]: Render color picker in RGB space with alpha. Field must be of typeegui::Color32,egui::Rgba. -
#[egui_probe(rgba_premultiplied)]: Render color picker in RGB space with premultiplied alpha. Foregui::Color32andegui::Rgbait is the same as#[egui_probe(rgba)]. But it can be used on[u8; 4]and[f32; 4]. -
#[egui_probe(rgba_unmultiplied)]: Render color picker in RGB space with unmultiplied alpha. It can't be used withegui::Color32andegui::Rgba, as those are always premultiplied. But it can be used on[u8; 4]and[f32; 4].
License
This project is licensed under either of
- MIT License
- Apache License, Version 2.0
at your option.
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
Enjoy building your UI with Egui Probe! 🚀