Ga naar hoofdinhoud

CnDeleteDialog

Two-phase single-item delete confirmation dialog. Shows a warning, waits for API response, then shows success or error.

Try it​

Loading CnDeleteDialog playground…

Wraps: NcDialog, NcButton, NcNoteCard, NcLoadingIcon

CnDeleteDialog confirmation dialog with warning text and Cancel/Delete buttons

CnDeleteDialog confirmation with warning text and Cancel/Delete buttons

Live demo​

<template>
<div>
<button @click="open = true" style="padding: 6px 16px; border-radius: 4px; background: var(--color-primary-element); color: white; border: none; cursor: pointer;">Delete item</button>
<CnDeleteDialog
v-if="open"
ref="dlg"
:item="{ id: 1, title: 'Annual Report 2024' }"
@confirm="onConfirm"
@close="open = false" />
</div>
</template>
<script>
export default {
data() { return { open: false } },
methods: {
async onConfirm(id) {
await new Promise(r => setTimeout(r, 800))
this.$refs.dlg.setResult({ success: true })
},
},
}
</script>

Props​

PropTypeDefaultDescription
itemObject(required)Item to delete (must have id)
nameFieldString'title'Field used as display name
nameFormatterFunctionnullOptional function (item) => string to format the display name. Overrides nameField when provided.
dialogTitleString'Delete Item'
warningTextString'Are you sure...'Supports \{name\} placeholder
successTextString'Item successfully deleted.'
cancelLabelStringCancel button label
closeLabelStringClose button label
confirmLabelStringConfirm button label

Events​

EventPayloadDescription
confirmidDelete confirmed by user
close—Dialog closed

Public Methods​

MethodDescription
setResult(\{ success?, error? \})Set operation result after API call

Custom Name Formatting​

When items don't have a simple name field, use nameFormatter to build a display name from any item properties:

<CnDeleteDialog
:item="auditTrail"
:name-formatter="(item) => t('myapp', 'Audit Trail #{id}', { id: item.id })"
@confirm="onDeleteConfirm"
@close="deleteItem = null" />

Two-Phase Pattern​

<template>
<CnDeleteDialog
v-if="deleteItem"
ref="deleteDialog"
:item="deleteItem"
@confirm="onDeleteConfirm"
@close="deleteItem = null" />
</template>

<script>
export default {
methods: {
async onDeleteConfirm(id) {
try {
await api.delete(id)
this.$refs.deleteDialog.setResult({ success: true })
} catch (error) {
this.$refs.deleteDialog.setResult({ error: error.message })
}
},
},
}
</script>

Board look​

Set look: "board" in the manifest (or pass look="board" to the dialog) and the dialog draws the board dialog of the screens. An app that sets nothing renders exactly as before.

PropDefaultWhat it does
lookfollows the appboard or nextcloud. The prop wins over the app.
widthper componentconfirm (560), form (640) or wizard (720). No other width is reachable.
eyebrowemptyA context line above the title, 13px in sentence case. Not part of the accessible name.
subtitleemptyA sentence under the title.

Widths are capped at the viewport minus 32px. Theme hooks: --cn-dialog-danger (fill of a destructive primary, default --color-error), --cn-dialog-eyebrow-color, --cn-dialog-eyebrow-transform (uppercase for capitals) and --cn-dialog-eyebrow-tracking.

Destructive wording and type-to-confirm​

In the board look the body opens with a sentence that names the item in bold ("Are you sure you want to permanently delete name? This action cannot be undone."). A warningText you set renders under it as a warning note. Pass :irreversible="false" to drop the last sentence.

Pass confirmValue to ask the user to type a value. The delete button stays disabled (aria-disabled="true", 45% opacity) until the field matches exactly. confirmFieldLabel labels the field; confirmLabel stays the button label. This holds in both looks. CnMassDeleteDialog and CnConfirmDialog take the same props.

Reference (auto-generated)​

The tables below are generated from the SFC source via vue-docgen-cli. They reflect what's actually in CnDeleteDialog.vue and update automatically whenever the component changes.

OpenRegister reliance​

none: this component does not touch OpenRegister, directly or through anything it imports. 0 direct references, 0 files reached through imports.

See the reliance overview for the filterable list.

Props​

NameTypeRequiredDefaultDescription
confirmValuestring''Value the user must type before the destructive button enables. Empty: no field.
confirmFieldLabelstring() =&gt; t('nextcloud-vue', 'Type to confirm')Label of the type-to-confirm field.
itemobject✓—The item to delete. Must have an id property.
nameFieldstring'title'Property name used for display (e.g., 'title', 'name')
nameFormatterfuncnullOptional function to format the item name. Receives the item, returns a string. Overrides nameField when provided.
dialogTitlestring() =&gt; t('nextcloud-vue', 'Delete item')Dialog title
warningTextstring() =&gt; t('nextcloud-vue', 'Are you sure you want to permanently delete "\{name\}"? This action cannot be undone.')Warning text. Use {name} as placeholder for the item name.
successTextstring() =&gt; t('nextcloud-vue', 'Item successfully deleted.')Success message
cancelLabelstring() =&gt; t('nextcloud-vue', 'Cancel')Label for the cancel button (visible before the delete runs).
closeLabelstring() =&gt; t('nextcloud-vue', 'Close')Label for the close button (visible after delete completes).
confirmLabelstring() =&gt; t('nextcloud-vue', 'Delete')Label for the primary confirm button that triggers the delete.
irreversiblebooleantrueBoard look: end the sentence with "This action cannot be undone." Set false for a delete that can be undone (the item goes to a bin).

Events​

NamePayloadDescription
close—
confirm—

Methods​

NameDescription
setResultSet the result of the delete operation. Call this from the parent after the API call completes.