Script tag
Copy the vanilla file beside the page, import it as a module, and the dialog runs without a bundler.
Prerequisites
You need a modern browser and a page you can edit. Tailwind CSS v4 is loaded from the browser build for the demo; a production site can use its existing stylesheet instead.
- Any static server, or a file opened directly when the module import allows it.
- Tailwind CSS v4, either the browser build or your own compiled stylesheet.
- The theme variables the component reads: background, foreground, muted-foreground, accent, border and popover.
New page or existing page
Start with one HTML file. The browser build compiles the utility classes and the theme block without a package manager.
<!doctype html><html lang="en"><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>PrequelUI dialog</title><script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script><style type="text/tailwindcss">@custom-variant dark (&:where(.dark, .dark *));@theme inline {--color-background: var(--background);--color-foreground: var(--foreground);--color-muted-foreground: var(--muted-foreground);--color-accent: var(--accent);--color-border: var(--border);--color-popover: var(--popover);--color-popover-foreground: var(--popover-foreground);}:root {--background: oklch(1 0 0);--foreground: oklch(0.145 0 0);--muted-foreground: oklch(0.556 0 0);--accent: oklch(0.97 0 0);--border: oklch(0.922 0 0);--popover: oklch(1 0 0);--popover-foreground: oklch(0.145 0 0);}.dark {--background: oklch(0.145 0 0);--foreground: oklch(0.985 0 0);--muted-foreground: oklch(0.708 0 0);--accent: oklch(0.269 0 0);--border: oklch(1 0 0 / 10%);--popover: oklch(0.205 0 0);--popover-foreground: oklch(0.985 0 0);}</style></head><body class="grid min-h-svh place-items-center bg-background text-foreground"><div id="app"></div><script type="module">import { createDialog } from "./prequelui/dialog/dialog.js";createDialog(document.getElementById("app"), {trigger: "Open dialog",title: "A plain script",});</script></body></html>
The browser build is a demo shortcut. In production, keep your compiled Tailwind stylesheet and the same theme variables.
Copy the dialog
The framework-free item exports createDialog(root, options) and returns an object with setOpen and destroy. Copy it beside the page so you can tune its durations.
Copy the framework-free dialog
curl -fsSL --create-dirs https://prequeluianimate.terravidhal.me/r/vanilla/dialog/dialog.js -o prequelui/dialog/dialog.jsimport { createDialog } from "./prequelui/dialog/dialog.js";
const dialog = createDialog(document.getElementById("app"), {
trigger: "Open dialog",
title: "Project overview",
description: "A short description of the surface.",
});
// dialog.setOpen(true);
// dialog.destroy();Dark mode
Read the stored choice, then the system preference, and set the class before the module runs. The theme block above already defines the dark values.
<script>const saved = localStorage.getItem("theme");const dark =saved === "dark" ||(!saved && matchMedia("(prefers-color-scheme: dark)").matches);document.documentElement.classList.toggle("dark", dark);</script>
Verification
Serve the folder over HTTP so the module import resolves, then open the page.
- The trigger renders inside the target element.
- The dialog opens, traps the surface visually and closes from its buttons.
- Reduced motion removes the travel, not the state change.
Serve the folder
npx serve@latest .More JavaScript guides
All frameworks