Interface IDialog

interface IDialog {
    ask: ((message: string, options?: string | ConfirmDialogOptions) => Promise<boolean>);
    confirm: ((message: string, options?: string | ConfirmDialogOptions) => Promise<boolean>);
    message: ((message: string, options?: string | MessageDialogOptions) => Promise<void>);
    save: ((options?: SaveDialogOptions) => Promise<string | null>);
    open(options?: OpenDialogOptions): any;
}

Properties

Methods

Properties

ask: ((message: string, options?: string | ConfirmDialogOptions) => Promise<boolean>)

Type declaration

    • (message, options?): Promise<boolean>
    • Shows a question dialog with Yes and No buttons.

      Parameters

      • message: string

        The message to show.

      • Optionaloptions: string | ConfirmDialogOptions

        The dialog's options. If a string, it represents the dialog title.

      Returns Promise<boolean>

      A promise resolving to a boolean indicating whether Yes was clicked or not.

      import { ask } from '@tauri-apps/plugin-dialog';
      const yes = await ask('Are you sure?', 'Tauri');
      const yes2 = await ask('This action cannot be reverted. Are you sure?', { title: 'Tauri', kind: 'warning' });

      2.0.0

confirm: ((message: string, options?: string | ConfirmDialogOptions) => Promise<boolean>)

Type declaration

    • (message, options?): Promise<boolean>
    • Shows a question dialog with Ok and Cancel buttons.

      Parameters

      • message: string

        The message to show.

      • Optionaloptions: string | ConfirmDialogOptions

        The dialog's options. If a string, it represents the dialog title.

      Returns Promise<boolean>

      A promise resolving to a boolean indicating whether Ok was clicked or not.

      import { confirm } from '@tauri-apps/plugin-dialog';
      const confirmed = await confirm('Are you sure?', 'Tauri');
      const confirmed2 = await confirm('This action cannot be reverted. Are you sure?', { title: 'Tauri', kind: 'warning' });

      2.0.0

message: ((message: string, options?: string | MessageDialogOptions) => Promise<void>)

Type declaration

    • (message, options?): Promise<void>
    • Shows a message dialog with an Ok button.

      Parameters

      • message: string

        The message to show.

      • Optionaloptions: string | MessageDialogOptions

        The dialog's options. If a string, it represents the dialog title.

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { message } from '@tauri-apps/plugin-dialog';
      await message('Tauri is awesome', 'Tauri');
      await message('File not found', { title: 'Tauri', kind: 'error' });

      2.0.0

save: ((options?: SaveDialogOptions) => Promise<string | null>)

Type declaration

    • (options?): Promise<string | null>
    • Open a file/directory save dialog.

      The selected path is added to the filesystem and asset protocol scopes. When security is more important than the easy of use of this API, prefer writing a dedicated command instead.

      Note that the scope change is not persisted, so the values are cleared when the application is restarted. You can save it to the filesystem using tauri-plugin-persisted-scope.

      Parameters

      • Optionaloptions: SaveDialogOptions

      Returns Promise<string | null>

      A promise resolving to the selected path.

      import { save } from '@tauri-apps/plugin-dialog';
      const filePath = await save({
      filters: [{
      name: 'Image',
      extensions: ['png', 'jpeg']
      }]
      });

      2.0.0

Methods