A cross-platform library for displaying native dialogs in Rust. On Windows and macOS, this library uses native system dialogs (Win32 TaskDialog and AppKit). On Linux, the backend is a pure Rust software renderer (winit + tiny-skia) with no C/C++ build dependencies, making it fully compatible with static musl builds. This allows for a simplified API and consistent behavior across platforms.
This is not a replacement for a proper GUI framework. It is meant to be used for CLI / background applications which occasionally need to show dialogs (such as alerts, or progress) to the user.
It's main use-case is for the Velopack application installation and update framework.
- Cross-platform: works on Windows, macOS, and Linux
- Native backends on Windows (Win32) and macOS (AppKit) with zero additional build dependencies
- Pure Rust software-rendered backend on Linux (no C/C++ dependencies, static musl compatible)
- Embedded font (Ubuntu) - no system font dependencies on Linux
- Simple and consistent API across all platforms
Add the following to your Cargo.toml:
[dependencies]
xdialog = "3.1.0"Or, run the following command:
cargo install xdialogSince some platforms require UI to be run on the main thread, xdialog expects to own the main thread, and will launch your core application logic in another thread.
use xdialog::*;
fn main() -> i32 {
XDialogBuilder::new().run(your_main_logic)
}
fn your_main_logic() -> i32 {
// ... do something here
let should_update_now = show_message_yes_no(
"My App Incorporated",
"New version available",
"Would you like to to the new version now?",
XDialogIcon::Warning,
).unwrap();
if !should_update_now {
return -1; // user declined the dialog
}
// ... do something here
let progress = show_progress(
"My App Incorporated",
"Main instruction",
"Body text",
XDialogIcon::Information
).unwrap();
progress.set_value(0.5).unwrap();
progress.set_text("Extracting...").unwrap();
std::thread::sleep(std::time::Duration::from_secs(3));
progress.set_value(1.0).unwrap();
progress.set_text("Updating...").unwrap();
std::thread::sleep(std::time::Duration::from_secs(3));
progress.set_indeterminate().unwrap();
progress.set_text("Wrapping Up...").unwrap();
std::thread::sleep(std::time::Duration::from_secs(3));
progress.close().unwrap();
0 // return exit code
}There are more examples in the examples directory.
cargo run --example various_options- Windows: Native Win32 TaskDialog API
- macOS: Native AppKit dialogs
- Linux: Pure Rust software renderer using winit + tiny-skia + cosmic-text. No C/C++ build dependencies, works with static musl linking, and embeds its own font (Ubuntu), falling back to system fonts for glyphs it doesn't cover (CJK, emoji, …).
[dependencies]
xdialog = "3.1.0"