Svelte Alert Dialog - Bitblue

Confirm destructive or important actions with a focused modal dialog

AlertDialog wraps a small Modal with a confirm / cancel pair. Bind open and handle onYes / onCancel in your app. Interactive open state belongs in route or example fences — not top-level markdown $state (SSR).

Setup

<script lang="ts">
	import { AlertDialog, Button } from '.';
</script>

Default

Bind open and handle onYes / onCancel:

<script lang="ts">
	import { AlertDialog, Button } from '.';
	let open = $state(false);
</script>

<Button color="red" onclick={() => (open = true)}>Delete item</Button>
<AlertDialog
	bind:open
	message="Are you sure you want to delete this item? This action cannot be undone."
	onYes={() => (open = false)}
	onCancel={() => (open = false)}
/>
Live confirm dialogs need local state — copy the example above into your route.

Custom confirm label and icon

<script lang="ts">
	import { AlertDialog, Button } from '.';
	let open = $state(false);
</script>

<Button color="red" onclick={() => (open = true)}>Archive</Button>
<AlertDialog
	bind:open
	message="Archive this project? You can restore it later."
	confirmText="Yes, archive"
	icon="mdi:archive-outline"
	iconColor="text-amber-500"
	onYes={() => (open = false)}
	onCancel={() => (open = false)}
/>

Busy / disable confirm

While an async action runs, set busy (shows a spinner on the confirm button) and optionally disableYes.

<script lang="ts">
	import { AlertDialog, Button } from '.';
	let open = $state(false);
	let busy = $state(false);

	async function confirm() {
		busy = true;
		await new Promise((r) => setTimeout(r, 800));
		busy = false;
		open = false;
	}
</script>

<Button color="red" onclick={() => (open = true)}>Delete</Button>
<AlertDialog
	bind:open
	{busy}
	message="Deleting…"
	onYes={confirm}
	onCancel={() => (open = false)}
/>

Form submit confirm

Set buttonType="submit" when the dialog sits inside a form and the confirm button should submit.

<script lang="ts">
	import { AlertDialog } from '.';
	let open = $state(false);
</script>

<form method="POST">
	<AlertDialog
		bind:open
		buttonType="submit"
		message="Submit this form?"
		onYes={() => {}}
		onCancel={() => (open = false)}
	/>
</form>

Props

PropTypeDefaultDescription
openbooleanfalseBindable visibility
messagestring''Body copy under the icon
iconstring'line-md:alert-circle'Iconify icon id
iconColorstring''Classes on the icon (e.g. text-red-500)
confirmTextstring"Yes, I'm sure"Confirm button label
buttonType'submit' | 'button' | 'reset''button'Confirm button type
disableYesbooleanfalseDisable confirm without busy UI
busybooleanfalseDisable both buttons + spinner on confirm
dismissablebooleantrueAllow modal dismiss (close / Esc / outside)
onYes() => void—Confirm callback (required)
onCancel() => void—Cancel callback (required)

© 2026 Bitblue is a registered trademark. All Rights Reserved.