Skip to content

Delete Confirmation Modal

Dark Bootstrap 5 modal that confirms deleting an item by typing its exact name, with per-row triggers, a loading state and removal of the deleted row.

Also known as: type to confirm delete, delete confirmation dialog, confirm deletion modal, destructive action modal

Bootstrap 5 Modals Responsive Dark #confirmation #dark #delete #dialog #modal

Delete Confirmation Modal live demo

Open in new tab

Bootstrap 5 code (HTML, CSS, JS)

A dark Bootstrap 5 delete confirmation modal that only enables the delete button after the user types the exact name of the item. It ships with a repository list where every row has its own delete button, which makes it a good fit for admin panels, developer dashboards and settings pages with destructive actions.

How it works

The root .mcd-wrap sets data-bs-theme="dark", so both the .mcd-card list and the .mcd-modal use Bootstrap's dark color mode. Each .mcd-item row has a .mcd-trigger button with data-bs-toggle="modal", data-bs-target="#mcd-modal" and a data-mcd-name attribute holding the item name. One modal serves all rows.

The script listens for Bootstrap's show.bs.modal event and reads event.relatedTarget to find the clicked button. It writes the name into .mcd-target and .mcd-target-code, clears the .mcd-input field and stores the name as the expected value. On shown.bs.modal the field receives focus. Every input event compares the value with the expected name; on an exact match the .mcd-confirm button is enabled and the field gets a green border through .mcd-input--match.

Submitting the form shows a spinner and the label "Deleting…", and hide.bs.modal is blocked while the request runs. After a simulated delay the modal closes, the row fades out with .mcd-item--leaving and is removed, .mcd-count is updated and .mcd-status announces the result.

Customization

  • --mcd-danger, --mcd-danger-dark and --mcd-danger-rgb in .mcd-wrap: change the red used for the triggers, the alert icon, the confirm button and the focus ring.
  • --mcd-warning in .mcd-wrap: recolor the hazard stripes in .mcd-stripe and the plan badge, or delete the .mcd-stripe element for a plain top edge.
  • --mcd-page-bg, --mcd-surface and --mcd-border in .mcd-wrap: adjust the dark background, the card and modal surface, and the divider lines.
  • --mcd-radius in .mcd-wrap: round or square the corners of the card and the modal.
  • data-mcd-name on each .mcd-trigger: the text the user must type; it can be any string, such as a project slug or an email address.
  • The .mcd-impact list: describe what your delete action removes.
  • The window.setTimeout call in the submit handler of script.js: replace it with a fetch() DELETE request to your API and keep the row removal for the success case.

Use cases

  • Admin panels: users must type the exact item name before a dangerous delete button becomes active
  • Developer dashboards: each repository row opens the same modal with its own name filled in
  • Settings pages: a loading state and row removal follow a confirmed delete
  • Project management tools: a list of impacts tells users what will be lost before they confirm

Accessibility

The modal is labelled by #mcd-modal-title and described by #mcd-modal-desc, and the input is linked to the case-sensitivity note with aria-describedby. Bootstrap traps focus inside the dialog and closes it with Escape. Because the clicked row is removed after a delete, the script moves focus to the next remaining delete button, or to the list heading when the list is empty, instead of losing it. Each row button has an aria-label that includes the item name, and the status line uses role="status". The row fade-out is skipped under prefers-reduced-motion: reduce.

Usage notes

Requires the Bootstrap 5.3 bundle and Bootstrap Icons. When using several instances on one page, give each modal, its input and its hint unique id values and update data-bs-target on the triggers.

Delete Confirmation Modal at a glance

Framework
Bootstrap 5
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Bootstrap 5, Bootstrap Icons
Layout
Responsive, works on mobile, dark design
Category
Modals
License
Free for personal and commercial use

Questions about this template

Can I use the Delete Confirmation Modal code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Bootstrap 5 and Bootstrap Icons from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
  • <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
Delete Confirmation Modal – free Bootstrap 5 modal template
Delete Confirmation Modal · free Bootstrap 5 modal template

More Modals

Multi-Step Wizard Dialog – free Bootstrap 6 modal template

Multi-Step Wizard Dialog

Bootstrap 6 Dialog wizard with three steps, a Stepper and progress bar, back/next buttons, per-step validation, Chips email invites and a review screen.

Image Lightbox Dialog – free Bootstrap 6 modal template

Image Lightbox Dialog

Dark Bootstrap 6 Dialog lightbox that opens gallery thumbnails large, with previous/next buttons, arrow-key and swipe navigation, captions and a photo counter.

Multi-Step Modal Dialog – free Tailwind CSS modal template

Multi-Step Modal Dialog

Tailwind CSS modal with a three-step wizard: template picker, validated details form and review, plus stepper, focus trap and Escape to close.

Product Quick View Modal with Photo – free Bootstrap 5 modal template

Product Quick View Modal with Photo

Bootstrap 5 product quick view modal with photo, rating, material and size options that update price and image, quantity stepper and add to cart.

Newsletter Popup Dialog – free Bootstrap 6 modal template

Newsletter Popup Dialog

Bootstrap 6 Dialog newsletter popup with a photo side, email signup with validation, a don't-show-again option, delayed auto-open and a confirmation state.

Fullscreen Dialog on Mobile – free Bootstrap 6 modal template

Fullscreen Dialog on Mobile

Dark Bootstrap 6 Dialog for notification settings that is centered on desktop, fullscreen on phones, with a scrollable body of switches and a sticky footer.