Vite + React
Two aliases to line up, one stylesheet to load, then the components behave like the rest of your app.
Prerequisites
You need Vite + React with React 19, Tailwind CSS v4 and an import alias. The CLI reads components.json to know where components, hooks and the cn helper live.
- Node.js 20 or newer, with the package manager you already use.
- React 19: the components pass ref as a regular prop.
- Tailwind CSS v4: the stylesheet starts with @import "tailwindcss";.
- An alias, @/* or ~/*, declared in tsconfig.json and resolved by the bundler.
New app or existing app
The React and TypeScript template gives you src/main.tsx and src/App.tsx. Tailwind and the alias are the two things to add before the registry can place files.
Create a Vite app
npx create-vite@latest my-app --template react-tsAlready have an app? Skip the scaffold, check the alias and Tailwind build, then continue at Configuration.
Configuration
Point @/* at src/ so the registry's components/prequelui and lib folders resolve, then wrap the app once so every primitive shares the same tempo and reduced-motion policy. The registry installs motion and lucide-react with the first component, so an explicit install is optional.
Install the dependencies yourself (optional)
npm install motion lucide-react{
"compilerOptions": {
"paths": {
"@/*": ["./src/*"]
}
}
}import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { PrequelMotionProvider } from "@/components/prequelui/motion";
import App from "./App";
import "./index.css";
createRoot(document.getElementById("root")!).render(
<StrictMode>
<PrequelMotionProvider tempo={1}>
<App />
</PrequelMotionProvider>
</StrictMode>,
);import path from "node:path";
import tailwindcss from "@tailwindcss/vite";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [react(), tailwindcss()],
resolve: {
alias: { "@": path.resolve(__dirname, "./src") },
},
});@import "tailwindcss";The provider imports the shared motion file that the first add writes. Run the next step before starting the dev server, or skip the provider and let each component use its own defaults.
Add a component
Run init once if the project has no components.json yet, then add the dialog. The file lands in components/prequelui and imports the shared motion helpers from the same folder.
Create components.json and the theme
npx shadcn@latest initAdd the animated component
npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/dialog.jsonimport { Dialog } from "@/components/prequelui/dialog";
export default function App() {
return (
<div className="grid min-h-svh place-items-center">
<Dialog trigger="Open dialog" title="A quiet entrance" />
</div>
);
}The add command writes the animated component and its shared motion helpers. Your markup stays yours: edit the installed file in place.
Dark mode
The theme switches under a .dark class on <html>. Read the saved choice before the first paint so the page never flashes the wrong theme.
<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
Import the component, open it, and check the motion rather than only the markup.
- The dialog opens with a veil and a small scale-and-blur entrance.
- Press Escape and the surface leaves faster than it arrived.
- Toggle the theme; the surface uses your theme variables, not hard-coded colours.
- Turn on the system reduced-motion setting; the overlay still changes state, without travel.
Start the dev server
npm run devMore React guides
All frameworks