ExTauri.Dialog (ex_tauri v0.2.0)
View SourceOpen native file and message dialogs from your LiveView.
Bridges to tauri-plugin-dialog via the LiveView hook.
Requirements
tauri-plugin-dialogmust be installed (see Plugin Setup below)- The
TauriHookmust be mounted in your LiveView (seeExTauri.Hook)
Plugin Setup
mix ex_tauri.add dialogThis adds the Cargo dependency, registers the plugin in main.rs, and adds
the dialog:default capability. See Mix.Tasks.ExTauri.Add for details.
Examples
# Open file picker
def handle_event("open_file", _params, socket) do
socket = ExTauri.Dialog.open(socket, title: "Select a file")
{:noreply, socket}
end
# Handle the response
def handle_event("tauri_response", %{"command" => "dialog_open", "path" => path}, socket) do
{:noreply, assign(socket, :selected_file, path)}
end
Summary
Functions
Shows an ask dialog with Yes/No buttons.
Shows a confirmation dialog with Yes/No buttons.
Shows a message dialog (alert).
Opens a file selection dialog.
Opens a file save dialog.
Functions
Shows an ask dialog with Yes/No buttons.
Similar to confirm/3 but uses Tauri's ask dialog variant.
Options
:title- Dialog window title:ok_label- Custom label for the OK/Yes button:cancel_label- Custom label for the Cancel/No button
Examples
ExTauri.Dialog.ask(socket, "Do you want to save changes before closing?")
Shows a confirmation dialog with Yes/No buttons.
The result will be sent back as a "tauri_response" event with
%{"command" => "dialog_message", "result" => true | false}.
Options
:title- Dialog window title:ok_label- Custom label for the OK/Yes button:cancel_label- Custom label for the Cancel/No button
Examples
ExTauri.Dialog.confirm(socket, "Are you sure you want to delete this?")
Shows a message dialog (alert).
Options
:title- Dialog window title:ok_label- Custom label for the OK button
Examples
ExTauri.Dialog.message(socket, "Operation completed successfully!")
Opens a file selection dialog.
Options
:title- Dialog window title:default_path- Starting directory or file path:multiple- Allow selecting multiple files (default: false):directory- Select directories instead of files (default: false):filters- List of file filters, e.g.[%{name: "Images", extensions: ["png", "jpg"]}]
Examples
ExTauri.Dialog.open(socket, title: "Select an image", filters: [%{name: "Images", extensions: ["png", "jpg"]}])
ExTauri.Dialog.open(socket, directory: true, title: "Select folder")
Opens a file save dialog.
Options
:title- Dialog window title:default_path- Starting directory or default file name:filters- List of file filters
Examples
ExTauri.Dialog.save(socket, title: "Save as", default_path: "document.txt")