Skip to content

Preventing close

Modals can prevent themselves from closing by using onBeforeClose. If the provided callback returns false the modal will not close.

<script>
import { onBeforeClose } from 'svelte-modals'
const { isOpen, close } = $props()
let canClose = $state(true)
onBeforeClose(() => {
return canClose
})
</script>