Documentation Upgrade
Start here
CwDialog wraps a native `<dialog>` element with the behavior most apps want by default: open state binding, title, actions, escape handling, and backdrop close.
Copy-paste examples
These snippets intentionally show the full public API surface the live demo relies on.
Confirmation dialog
The parent owns the `open` state and the action buttons close the dialog explicitly.
<script lang="ts">
let confirmOpen = $state(false);
</script>
<CwButton onclick={() => (confirmOpen = true)}>Delete zone</CwButton>
<CwDialog bind:open={confirmOpen} title="Delete zone">
{#snippet children()}
<p>This removes the zone and its alert rules.</p>
{/snippet}
{#snippet actions()}
<CwButton variant="ghost" onclick={() => (confirmOpen = false)}>Cancel</CwButton>
<CwButton variant="danger" onclick={() => (confirmOpen = false)}>Delete</CwButton>
{/snippet}
</CwDialog>
Blocking dialog
Only use this pattern when the user must complete an intentional workflow.
<script lang="ts">
let blockingOpen = $state(true);
let closed = $state(false);
</script>
<CwDialog
bind:open={blockingOpen}
title="Required acknowledgement"
closeOnBackdrop={false}
closeOnEscape={false}
onclose={() => (closed = true)}
>
{#snippet children()}
<p>Read the maintenance notice before continuing.</p>
{/snippet}
{#snippet actions()}
<CwButton onclick={() => (blockingOpen = false)}>I understand</CwButton>
{/snippet}
</CwDialog>