Confirmation dialog in HTML and CSS
A small window asking to confirm an action before running it.
Here is an excerpt of this component's code in HTML and CSS. The full code is free for members, ready to copy into your project.
This component also comes in
The code in HTML and CSS
document.querySelectorAll("[data-dialog-open]").forEach((button) => {
const dialog = document.getElementById(button.dataset.dialogOpen);
button.addEventListener("click", () => dialog.showModal());
});
document.querySelectorAll("dialog").forEach((dialog) => {
dialog.addEventListener("click", (event) => {
if (event.target === dialog) dialog.close();
});
dialog.querySelectorAll("[data-dialog-close]").forEach((button) => {
button.addEventListener("click", () => dialog.close(button.value));
});<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Fenêtre de confirmation</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<main class="demo">
<button type="button" class="trigger" data-dialog-open="confirm-dialog">Annuler ma réservation</button>
<dialog id="confirm-dialog" aria-labelledby="confirm-title" aria-describedby="confirm-text">:root {
--modal-bg: #ffffff;
--modal-text: #0f172a;
--modal-muted: #475569;
--modal-line: #cbd5e1;
--modal-accent: #1d4ed8;
--modal-accent-text: #ffffff;
--modal-ring: #1d4ed8;
--demo-bg: #f1f5f9;
--demo-text: #0f172a;
}
Free component: copy it freely, including for commercial projects.
Other modals components in HTML and CSS
Modals components in HTML and CSS
Age verification
FreeA legal-age check window for a wine shop or brewery, accessible, remembered for the session and with the French Evin law notices.
- Tailwind
- React
- CSS
- WordPress

A search covering the page, with popular suggestions, opened from the navigation bar.
- Tailwind
- React
- CSS
- WordPress

A short form in a window to request a call from an advisor.
- Tailwind
- React
- CSS
- WordPress