Back to InstallationYou are on Vite + JavaScript.
Installation

Vite + JavaScript

Vite gives the vanilla file a dev server and a build; the dialog keeps its own motion and styles.

JavaScriptSingle-page appsVanilla TypeScript and the framework-free dialog in Vite.

Prerequisites

You need a Vite app with the vanilla TypeScript template and Tailwind CSS v4. There is no framework alias to add, only a folder for the copied file.

  • Node.js 20 or newer.
  • Vite with the vanilla-ts template.
  • Tailwind CSS v4 through @tailwindcss/vite.
  • A src/prequelui folder for the framework-free item.

New app or existing app

Create a Vite app with the vanilla TypeScript template, or keep the app you already have. src/main.ts is the entry.

Create a Vite + JavaScript app

npx create-vite@latest my-app --template vanilla-ts
npmthe default on every machine

Existing app? Skip the scaffold and start with the configuration section.

Configuration

Add Tailwind to the Vite pipeline, install the motion runtime the animated files import, and point the stylesheet at src/style.css. No provider is needed.

Install Tailwind CSS v4

npm install tailwindcss @tailwindcss/vite
npmthe default on every machine

Install the motion runtime

npm install motion
npmthe default on every machine
vite.config.ts
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [tailwindcss()],
});
src/style.css
@import "tailwindcss";

Copy the dialog

Copy the framework-free item into src/prequelui, then import it from the entry. The dialog itself only uses CSS; the other animated items import motion, which the previous step installed.

Copy the framework-free dialog

shell
curl -fsSL --create-dirs https://prequeluianimate.terravidhal.me/r/vanilla/dialog/dialog.js -o src/prequelui/dialog/dialog.js
src/main.ts
import "./style.css";
import { createDialog } from "./prequelui/dialog/dialog.js";

createDialog(document.getElementById("app")!, {
  trigger: "Open dialog",
  title: "A Vite + JavaScript page",
});

Dark mode

Vite serves index.html before the module graph, so the class is in place on the first paint.

index.html
<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

Run the dev server, open the page and trigger the dialog. Then test the theme and reduced motion.

  • The trigger renders inside the app root.
  • The surface uses the theme tokens in light and dark.
  • Reduced motion keeps the state change without travel.

Start the dev server

npm run dev
npmthe default on every machine

More JavaScript guides

All frameworks

Built by Vidhal. The source is available on GitHub.

MIT licensed