Dialog
Native system dialogs for opening and saving files along with message dialogs.
Setup
Install the dialog plugin to get started.
Use your project’s package manager to add the dependency:
-
Run the following command in the
src-tauri
folder to add the plugin to the project’s dependencies inCargo.toml
: -
Modify
lib.rs
to initialize the plugin: -
If you’d like create dialogs in JavaScript, install the npm package as well:
Usage
The dialog plugin is available in both JavaScript and Rust. Here’s how you can use it:
in JavaScript:
- Create Yes/No Dialog
- Create Ok/Cancel Dialog
- Create Message Dialog
- Open a File Selector Dialog
- Save to File Dialog
in Rust:
JavaScript
See all Dialog Options at the JavaScript API reference.
Create Yes/No Dialog
Shows a question dialog with Yes
and No
buttons.
Create Ok/Cancel Dialog
Shows a question dialog with Ok
and Cancel
buttons.
Create Message Dialog
Shows a message dialog with an Ok
button. Keep in mind that if the user closes the dialog it will return false
.
Open a File Selector Dialog
Open a file/directory selection dialog.
The multiple
option controls whether the dialog allows multiple selection or not, while the directory
, whether is a directory selection or not.
Save to File Dialog
Open a file/directory save dialog.
Rust
Refer to the Rust API reference to see all available options.
Build an Ask Dialog
Shows a question dialog with Absolutely
and Totally
buttons.
If you need a non blocking operation you can use show()
instead:
Build a Message Dialog
Shows a message dialog with an Ok
button. Keep in mind that if the user closes the dialog it will return false
.
If you need a non blocking operation you can use show()
instead:
Build a File Selector Dialog
Pick Files
If you need a non blocking operation you can use pick_file()
instead:
Save Files
or, alternatively:
Default Permission
This permission set configures the types of dialogs available from the dialog plugin.
Granted Permissions
All dialog types are enabled.
allow-ask
allow-confirm
allow-message
allow-save
allow-open
Permission Table
Identifier | Description |
---|---|
|
Enables the ask command without any pre-configured scope. |
|
Denies the ask command without any pre-configured scope. |
|
Enables the confirm command without any pre-configured scope. |
|
Denies the confirm command without any pre-configured scope. |
|
Enables the message command without any pre-configured scope. |
|
Denies the message command without any pre-configured scope. |
|
Enables the open command without any pre-configured scope. |
|
Denies the open command without any pre-configured scope. |
|
Enables the save command without any pre-configured scope. |
|
Denies the save command without any pre-configured scope. |
© 2024 Tauri Contributors. CC-BY / MIT