API

Available options

openDialog

Utility function used to open dialogs with the specified component and options. Returns a reference to the created Dialog on which the user can then define callbacks and can close the dialog.

Name Description
component: T The svelte component to be opened as the content of the dialog. Has to be a svelte component.
options: Partial<DialogOptions<T>> The options and context passed to the dialog.

DialogOptions

Interface that holds the options passed to the dialog upon opening it.

Name Description
closeOnBackdropClick Whether to close the dialog when clicking the backdrop or not. This will only be applied if modal is set to true. Default: false
closeOnEsc Whether to close the dialog when the escape key is pressed or not. This will only be applied if modal is set to true. Default: true
disableScroll Whether to disable scrolling the page while the dialog is open or not. Default: false
modal Whether the dialog should be opened as a modal or not. Default: true
transition The transition function used when opening and closing the modal. Default: {fade} from svelte/transition
transitionOptions Extra options to be passed to transition.
context Props to be passed to the component.

Dialog

Class that represents a dialog opened by openDialog.

Name Description
onClose Close handler for the dialog. Will be called after manually closing the dialog with the close method.
onBackdropClicked Backdrop click handler for the dialog, which will be called when clicking on the backdrop. Will be called even if closeOnBackdropClick is set to false.
onEscapePressed/td> Escape button handler for the dialog, which will be called when pressing the escape key. Will be called even if closeOnEsc is set to false.
close Function that closes the dialog manually. Can be passed a result that will then be further passed down to the onClose handler.

dialogs

Svelte writable that holds all open dialogs. Can be used for custom open/close logic.