tfd
A pure Rust implementation of the tinyfiledialogs library, based on the original C library by Guillaume Vareille.
Features
- Cross-platform native dialog boxes (macOS, Linux/Unix, Windows)
- Message boxes (info, warning, error, question)
- Input boxes (with optional password mode)
- File open/save dialogs
- Folder selection
- Color picker
- System notifications
Security Warning
tinyfiledialogs should only be used with trusted input. Using it with untrusted input, for example as dialog title or message, can in the worst case lead to execution of arbitrary commands.
Installation
Add this to your Cargo.toml:
[]
= "1.0.0"
Examples
Message Box
use tinyfiledialogs as tfd;
// Simple message box
new
.with_icon
.run_modal;
// Yes/No dialog
let result = new
.with_icon
.run_modal_yes_no;
if result == Yes else
// Yes/No/Cancel dialog
let result = new
.with_icon
.run_modal_yes_no_cancel;
match result
Input Box
use tinyfiledialogs as tfd;
// Simple input
let name = new
.with_default
.run_modal;
if let Some = name
// Password input
let password = new
.password
.run_modal;
if let Some = password
File Dialogs
use tinyfiledialogs as tfd;
// Open file dialog
let file = new
.with_filter
.open_file;
if let Some = file
// Open multiple files
let files = new
.with_filter
.with_multiple_selection
.open_files;
if let Some = files
// Save file dialog
let file = new
.with_filter
.save_file;
if let Some = file
// Select folder
let folder = new
.select_folder;
if let Some = folder
Color Chooser
use tinyfiledialogs as tfd;
// Color picker with default black
let color_result = new
.run_modal;
if let Some = color_result
// Color picker with default color
let color_result = new
.with_default_color // Default red
.run_modal;
if let Some = color_result
Notifications
use tinyfiledialogs as tfd;
// Simple notification
new
.show;
// Notification with sound and subtitle
new
.with_subtitle
.with_sound // "Default", "IM", "Mail", "Reminder", etc.
.show;
// Platform-specific behavior:
// - macOS: Uses native notifications via AppleScript
// - Linux: Uses notify-send, zenity, or kdialog
// - Windows: Uses Toast notifications on Win10+ or message boxes on older versions
Platform-specific Notes
macOS
Dialogs on macOS are implemented using AppleScript.
Linux/Unix
Dialogs on Linux/Unix use the following programs in order of preference:
- zenity
- kdialog
- Xdialog
- dialog
If none are available, it falls back to console/terminal.
Windows
Dialogs on Windows use the native Windows API:
- Dialog boxes use standard Win32 API functions
- File dialogs use the Common Dialog API
- Color picker uses the Common Dialog API
- Notifications use Toast Notifications on Windows 10+ and fallback to message boxes on older versions
License
This project is licensed under the MIT License - see the LICENSE file for details.