Skip to content

Callback request dialog in HTML and CSS

A short form in a window to request a call from an advisor.

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

Open in a new tab

The code in HTML and CSS

dialog.js
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));
  });
index.html
<!doctype html>
<html lang="fr">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Fenêtre de demande de rappel</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <main class="demo">
      <button type="button" class="call-trigger" data-dialog-open="callback-dialog">Être rappelé gratuitement</button>
      <dialog id="callback-dialog" aria-labelledby="callback-title">
style.css
:root {
  --call-bg: #ffffff;
  --call-text: #042f2e;
  --call-line: rgb(4 47 46 / 0.3);
  --call-accent: #0f766e;
  --call-accent-text: #ffffff;
  --call-ring: #0f766e;
  --demo-bg: #f0fdfa;
  --demo-text: #042f2e;
}

@media (prefers-color-scheme: dark) {

Free component: copy it freely, including for commercial projects.

Modals components in HTML and CSS
  • A 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
    Component
  • A search covering the page, with popular suggestions, opened from the navigation bar.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A small window asking to confirm an action before running it.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component