@molecule/app-danger-zone-svelte
Feature · danger-zone · App (browser) · v1.1.2 · Apache-2.0
DangerZoneSection + ConfirmDialog for destructive actions (delete account, reset, revoke)
npm install @molecule/app-danger-zone-svelteHow it works
@molecule/app-danger-zone-svelte is a ready-made danger-zone feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.
<script lang="ts">
import { ConfirmDialog, DangerZoneSection } from '@molecule/app-danger-zone-svelte'
let confirmOpen = $state(false)
</script>
<DangerZoneSection
title="Delete account"
description="This permanently removes your account and all data."
actionLabel="Delete account"
onAction={() => (confirmOpen = true)}
/>
<ConfirmDialog
open={confirmOpen}
onClose={() => (confirmOpen = false)}
title="Delete account?"
description="This action cannot be undone."
confirmLabel="Delete"
onConfirm={handleDelete}
/>Works with: @molecule/app-svelte, @molecule/app-ui, @molecule/app-ui-svelte
Reference
Svelte destructive-action primitives — the counterpart of
@molecule/app-danger-zone-react: the same props and the same DOM for the
same input.
Exports <DangerZoneSection> — Card with title/description/button for
delete/reset/revoke — and <ConfirmDialog>, the standalone "Are you
sure?" modal.
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
<script lang="ts">
import { ConfirmDialog, DangerZoneSection } from '@molecule/app-danger-zone-svelte'
let confirmOpen = $state(false)
</script>
<DangerZoneSection
title="Delete account"
description="This permanently removes your account and all data."
actionLabel="Delete account"
onAction={() => (confirmOpen = true)}
/>
<ConfirmDialog
open={confirmOpen}
onClose={() => (confirmOpen = false)}
title="Delete account?"
description="This action cannot be undone."
confirmLabel="Delete"
onConfirm={handleDelete}
/>
Type
feature
Installation
npm install @molecule/app-danger-zone-svelte @molecule/app-svelte @molecule/app-ui @molecule/app-ui-svelte svelte
API
Interfaces
DangerZoneSectionProps
Props accepted by the DangerZoneSection component.
interface DangerZoneSectionProps {
/** Section title. */
title?: ReactNodeProp
/** Explanation of the destructive action. */
description?: ReactNodeProp
/** Label on the action button (e.g. "Delete account"). */
actionLabel?: ReactNodeProp
/** Called when the button is clicked. */
onAction?: (event: MouseEvent) => void
/** When true, the button disables and shows a loading label. */
loading?: boolean
/** When true, the button is disabled without loading. */
disabled?: boolean
/** Additional content between description and button (e.g. a confirm-text input). */
children?: Snippet
/** Extra classes on the Card. */
className?: string
/** `data-mol-id` for AI-agent selectors. */
dataMolId?: string
}
ConfirmDialogProps
Props for ConfirmDialog.
interface ConfirmDialogProps {
/** Whether the dialog is open. */
open: boolean
/** Called when the dialog should close (escape, backdrop, cancel). */
onClose: () => void
/** Title. */
title?: Snippet | string
/** Body / warning text. */
description?: Snippet | string
/** Confirm-button label (e.g. "Delete"). */
confirmLabel?: Snippet | string
/** Cancel-button label. */
cancelLabel?: Snippet | string
/** Called when the user confirms. */
onConfirm: () => void | Promise<void>
/** Is the confirm action destructive? Defaults to true. */
destructive?: boolean
/** Extra body content between description and footer. */
children?: Snippet
/** Disables both buttons while the confirm action is pending. */
loading?: boolean
/** Any extra props. */
[key: string]: unknown
}
Constants
DangerZoneSection
const DangerZoneSection: LegacyComponentType
ConfirmDialog
const ConfirmDialog: LegacyComponentType
Injection Notes
Requirements
Peer dependencies:
@molecule/app-svelte^3.5.0 || ^4.0.0@molecule/app-ui^1.0.1@molecule/app-ui-svelte^1.1.0svelte^5.0.0
Runtime Dependencies
@molecule/app-svelte@molecule/app-ui@molecule/app-ui-sveltesvelte
<ConfirmDialog> does NOT track onConfirm's promise and does NOT close
itself on confirm: set loading yourself while the action runs, then call
onClose() when it settles — otherwise users can double-fire the
destructive action or be left staring at an open dialog. Cancel/Confirm
fall back to the confirm.* i18n keys (companion bond:
@molecule/app-locales-danger-zone); pass confirmLabel/cancelLabel
for action-specific wording ("Delete", "Revoke"). destructive (default
true) only switches the confirm button color.
Translations
Translation strings are provided by @molecule/app-locales-danger-zone.