Vite + JavaScript
Vite gives the vanilla file a dev server and a build; the dialog keeps its own motion and styles.
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-tsExisting 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/viteInstall the motion runtime
npm install motionimport tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [tailwindcss()],
});@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
curl -fsSL --create-dirs https://prequeluianimate.terravidhal.me/r/vanilla/dialog/dialog.js -o src/prequelui/dialog/dialog.jsimport "./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.
<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 devMore JavaScript guides
All frameworks