Overview Button Copy button Field Input Number field Textarea Select Combobox Multiselect Date picker Date range picker Date-time picker Checkbox Radio group Position picker Switch Slider Dropzone Device controls Avatar Badge Card Collapsible Kbd Map Matrix Proportion bar Separator Stat Table Timeline Chat Playback Pagination Charts Chart theming Profile chart Time series chart Bar chart Isopleth chart TS diagram Box plot Rose chart Calendar chart Banner Toast Loader Progress Skeleton Empty state Error state Dropdown menu Tooltip Info tooltip Dialog Sheet Resizable Confirm dialog Breadcrumbs Command palette Mobile menu Navigation list Outline Scroll rail Sidebar Tabs
Confirm dialog
Asks before something that can't be undone. One dialog for the whole app, opened with a call that waits for the answer, so the code that asks reads top to bottom.
Examples
Set up
The provider renders the dialog and gives everything below it the confirm call.
<!-- Once, in the root layout -->
<ConfirmDialogProvider>
{@render children()}
</ConfirmDialogProvider> Asking
const confirm = getConfirm();
async function remove() {
const ok = await confirm({
title: 'Delete project',
message: 'Starefoss ledning, its 14 missions and all their data are deleted.',
confirmText: 'Delete project',
variant: 'danger',
confirmInput: project.name,
pendingText: 'Deleting...',
action: () => deleteProject(project.id),
});
if (ok) goto('/projects');
} Rules
- Only before something that can’t be undone or is costly to redo. Asking every time trains people to click through.
- The title is the question or the action; the message says what will happen, with the names and numbers.
- The confirm button repeats the action ("Delete project"), so it reads on its own. Cancel stays Cancel, or says what is kept.
- danger for deletes and anything else that can’t be undone, primary otherwise.
- Type to confirm only for the worst: a project, an account, an organisation. Matching ignores case and stray spaces.
- Pass the work as action and the button shows the pending text while it runs. The dialog stays open if it fails.