Skip to main content
Create new
Introduction
Reactivity
Props
Logic
Events
Bindings
Lifecycle
Stores
Motion
Transitions
Animations
Easing
SVG
Actions
Classes
Component composition
Context API
Special elements
Module context
Debugging
7GUIs
Miscellaneous
App.svelte
ConfirmModal.svelte
<script>
import { onMount } from 'svelte'
import { Modals, openModal, closeModal } from 'svelte-modals@next'
import ConfirmModal from './ConfirmModal.svelte'

async function handleDelete() {
const confirmed = await openModal(ConfirmModal, {
message: 'This will delete very important data. Are you sure?'
})

if (confirmed) {
const absolutelyConfirmed = await openModal(ConfirmModal, {
message: 'Are you absolutely sure?'
})

if (absolutelyConfirmed) {
alert('deleted!')
}
}
}
</script>

<button on:click={handleDelete}>Delete Important Data</button>

<Modals>
<div
slot="backdrop"
class="backdrop"
on:click={closeModal}
/>
</Modals>

<style>
.backdrop {
position: fixed;
top: 0;
loading Svelte compiler...
/* Select a component to see its compiled code */
result = svelte.compile(source, {
generate: ,
});
/* Select a component to see its compiled code */