Vite + Vue
The Vue registry items keep their props and transitions, and Vite serves them without a server runtime.
Prerequisites
You need a Vite app with Vue 3, Tailwind CSS v4 and the @/* alias. shadcn-vue's init writes components.json and the cn helper.
- Node.js 20 or newer.
- Vue 3 with the vue-ts template.
- Tailwind CSS v4 through @tailwindcss/vite, not the Tailwind v3 module.
- The @/* alias in both tsconfig files and in vite.config.ts.
New app or existing app
Create a Vite app with the Vue and TypeScript template, or keep the app you already have. The default src/style.css becomes the Tailwind entry.
Create a Vite + Vue app
npx create-vite@latest my-app --template vue-tsExisting app? Skip the scaffold and start with the configuration section.
Configuration
Install Tailwind as a Vite plugin, point the stylesheet at src/style.css and make @/* resolve to src. Then run the Vue registry init once.
Install Tailwind CSS v4
npm install tailwindcss @tailwindcss/viteAdd the Node types used by the alias
npm install @types/node -DCreate components.json and the theme
npx shadcn-vue@latest init -t vite -dimport path from "node:path";
import tailwindcss from "@tailwindcss/vite";
import vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [vue(), tailwindcss()],
resolve: {
alias: { "@": path.resolve(__dirname, "./src") },
},
});{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
],
"compilerOptions": {
"paths": {
"@/*": ["./src/*"]
}
}
}{
"compilerOptions": {
"paths": {
"@/*": ["./src/*"]
}
}
}@import "tailwindcss";declare module "*.vue" {
import type { DefineComponent } from "vue";
const component: DefineComponent<{}, {}, any>;
export default component;
}Add a component
Run the Vue CLI from the project root. It reads components.json, writes the dialog and installs motion and @lucide/vue.
Add the animated component
npx shadcn-vue@latest add https://prequeluianimate.terravidhal.me/r/vue/dialog.json<script setup lang="ts">
import Dialog from "@/components/prequelui/Dialog.vue";
</script>
<template>
<main class="grid min-h-svh place-items-center">
<Dialog trigger="Open dialog" title="A Vite + Vue page" />
</main>
</template>Dark mode
Vite is a single-page app, so index.html can set the class before the bundle paints. The saved choice wins, then the system preference.
<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 and open the page. Trigger the dialog, switch the theme, then enable reduced motion in the OS.
- The dialog opens and closes from the trigger, with Escape working.
- The surface uses the theme tokens in both light and dark.
- Reduced motion removes the scale and blur, not the state change.
Start the dev server
npm run devMore Vue guides
All frameworks