{"slug":"alert-dialog","name":"AlertDialog","category":"Overlays","summary":"A blocking confirmation that returns a decision through an action.","status":"stable","since":"0.1.0","import":"import { AlertDialog } from '@elluzion/iv-ui';","usage":["Mount `<AlertDialog />` once in the root layout, then open it with `showAlertDialog({ ... })`.","`actions` defaults to a single `OK` button; give each action a `variant` that matches its weight.","Set `closeOnClick: false` to keep the dialog open, then close it yourself when the work finishes."],"props":[],"events":[],"snippets":[],"types":[],"manual":[{"title":"Functions","rows":[{"name":"showAlertDialog(config)","type":"AlertDialogState","description":"Opens the dialog with the given title, message, and actions."},{"name":"alertDialogState","type":"Writable<AlertDialogState | null>","description":"Store holding the current dialog, or `null` when closed."}]},{"title":"Config","note":"Passed to `showAlertDialog`.","rows":[{"name":"title","type":"string","description":"Dialog title and accessible name."},{"name":"message","type":"string","description":"Body text describing the decision."},{"name":"actions","type":"AlertDialogAction[]","description":"Buttons rendered in order; defaults to one `OK` action."},{"name":"closeOnBackdrop","type":"boolean","description":"Closes when the backdrop is clicked. Defaults to `true`."},{"name":"closeOnEscape","type":"boolean","description":"Closes on Escape. Defaults to `true`."},{"name":"onclose","type":"() => void","description":"Called after the dialog closes for any reason."}]},{"title":"Action","rows":[{"name":"label","type":"string","description":"Button text."},{"name":"variant","type":"'primary' | 'secondary' | 'outline' | 'ghost' | 'danger'","description":"Button emphasis."},{"name":"size","type":"'sm' | 'md' | 'lg'","description":"Button size."},{"name":"disabled","type":"boolean","description":"Disables the action."},{"name":"closeOnClick","type":"boolean","description":"Closes the dialog after the handler runs. Defaults to `true`."},{"name":"onClick","type":"() => void","description":"Runs before the dialog closes."}]}],"tokens":["--iv_blur","--iv_border","--iv_dialog-gap","--iv_dialog-sm","--iv_font-sans","--iv_font-ui","--iv_foreground","--iv_foreground-dim","--iv_leading-base","--iv_overlay","--iv_radius-lg","--iv_shadow-lg","--iv_spacing-2xl","--iv_spacing-lg","--iv_spacing-md","--iv_spacing-sm","--iv_spacing-xl","--iv_surface-raised","--iv_text-xl","--iv_z-overlay"],"cssHooks":["iv-alertdialog","iv-alertdialog-actions","iv-alertdialog-message","iv-alertdialog-title","iv-backdrop"],"accessibility":{"keyboard":[["Tab","Moves focus between the actions."],["Escape","Closes the dialog unless `closeOnEscape` is false."]],"notes":["The surface uses `role=\"alertdialog\"` and `aria-modal=\"true\"`.","Focus is trapped while open and restored when the dialog closes.","The title names the dialog; the message is linked through `aria-describedby`."]},"related":[{"title":"Dialog","summary":"A modal surface for focused tasks and confirmations.","url":"/components/dialog","kind":"Component"},{"title":"Sheet","summary":"A panel that slides in from an edge for secondary flows.","url":"/components/sheet","kind":"Component"},{"title":"Toast","summary":"A single transient notification driven by the toast store.","url":"/components/toast","kind":"Component"},{"title":"Button","summary":"Triggers an action or submits a form.","url":"/components/button","kind":"Component"}],"examples":[{"id":"confirm","title":"Confirm","description":"A title, a message, and a cancel/confirm pair.","code":"<script lang=\"ts\">\n\timport { AlertDialog, Button, showAlertDialog } from '@elluzion/iv-ui';\n\n\tlet published = $state(0);\n\n\tfunction confirm() {\n\t\tshowAlertDialog({\n\t\t\ttitle: 'Publish release?',\n\t\t\tmessage: 'The build will be promoted to production and the current version will be archived.',\n\t\t\tactions: [\n\t\t\t\t{ label: 'Cancel', variant: 'ghost' },\n\t\t\t\t{\n\t\t\t\t\tlabel: 'Publish',\n\t\t\t\t\tvariant: 'primary',\n\t\t\t\t\tonClick: () => (published += 1)\n\t\t\t\t}\n\t\t\t]\n\t\t});\n\t}\n</script>\n\n<div class=\"stack\">\n\t<Button variant=\"primary\" onclick={confirm}>Publish release</Button>\n\t<p class=\"readout\">published {published} times</p>\n\t<AlertDialog />\n</div>\n\n<style>\n\t.stack {\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\talign-items: center;\n\t\tgap: var(--iv_spacing-sm);\n\t}\n\n\t.readout {\n\t\tmargin: 0;\n\t\tfont-family: var(--iv_font-mono);\n\t\tfont-size: var(--iv_text-sm);\n\t\tcolor: var(--iv_foreground-dim);\n\t}\n</style>"},{"id":"destructive","title":"Destructive","description":"A danger action with the delete verb in the label.","code":"<script lang=\"ts\">\n\timport { Button, showAlertDialog } from '@elluzion/iv-ui';\n\n\tlet deleted = $state(false);\n\n\tfunction remove() {\n\t\tshowAlertDialog({\n\t\t\ttitle: 'Delete project?',\n\t\t\tmessage: 'Orbital and its deployments will be removed. This cannot be undone.',\n\t\t\tactions: [\n\t\t\t\t{ label: 'Cancel', variant: 'ghost' },\n\t\t\t\t{\n\t\t\t\t\tlabel: 'Delete project',\n\t\t\t\t\tvariant: 'danger',\n\t\t\t\t\tonClick: () => (deleted = true)\n\t\t\t\t}\n\t\t\t]\n\t\t});\n\t}\n</script>\n\n<div class=\"stack\">\n\t<Button variant=\"danger\" onclick={remove}>Delete project</Button>\n\t{#if deleted}<p class=\"readout\">project deleted</p>{/if}\n</div>\n\n<style>\n\t.stack {\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\talign-items: center;\n\t\tgap: var(--iv_spacing-sm);\n\t}\n\n\t.readout {\n\t\tmargin: 0;\n\t\tfont-family: var(--iv_font-mono);\n\t\tfont-size: var(--iv_text-sm);\n\t\tcolor: var(--iv_error);\n\t}\n</style>"},{"id":"custom-actions","title":"Custom actions","description":"Several actions, each with its own variant and handler.","code":"<script lang=\"ts\">\n\timport { Button, showAlertDialog } from '@elluzion/iv-ui';\n\n\tlet last = $state('none');\n\n\tfunction choose() {\n\t\tshowAlertDialog({\n\t\t\ttitle: 'Unsaved changes',\n\t\t\tmessage: 'Leave the editor and lose the draft, or keep working?',\n\t\t\tcloseOnBackdrop: false,\n\t\t\tactions: [\n\t\t\t\t{\n\t\t\t\t\tlabel: 'Keep editing',\n\t\t\t\t\tvariant: 'ghost',\n\t\t\t\t\tonClick: () => (last = 'keep editing')\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: 'Discard',\n\t\t\t\t\tvariant: 'danger',\n\t\t\t\t\tonClick: () => (last = 'discarded')\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: 'Save draft',\n\t\t\t\t\tvariant: 'primary',\n\t\t\t\t\tonClick: () => (last = 'saved')\n\t\t\t\t}\n\t\t\t]\n\t\t});\n\t}\n</script>\n\n<div class=\"stack\">\n\t<Button variant=\"outline\" onclick={choose}>Close editor</Button>\n\t<p class=\"readout\">last choice: {last}</p>\n</div>\n\n<style>\n\t.stack {\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\talign-items: center;\n\t\tgap: var(--iv_spacing-sm);\n\t}\n\n\t.readout {\n\t\tmargin: 0;\n\t\tfont-family: var(--iv_font-mono);\n\t\tfont-size: var(--iv_text-sm);\n\t\tcolor: var(--iv_foreground-dim);\n\t}\n</style>"}],"markdown":"/components/alert-dialog.md","page":"/components/alert-dialog"}