Back to InstallationYou are on Vite + Vue.
Installation

Vite + Vue

The Vue registry items keep their props and transitions, and Vite serves them without a server runtime.

VueSingle-page appsVue 3, TypeScript and the @ alias in a Vite app.

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-ts
npmthe default on every machine

Existing 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/vite
npmthe default on every machine

Add the Node types used by the alias

npm install @types/node -D
npmthe default on every machine

Create components.json and the theme

npx shadcn-vue@latest init -t vite -d
npmthe default on every machine
vite.config.ts
import 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") },
  },
});
tsconfig.json
{
  "files": [],
  "references": [
    { "path": "./tsconfig.app.json" },
    { "path": "./tsconfig.node.json" }
  ],
  "compilerOptions": {
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}
tsconfig.app.json
{
  "compilerOptions": {
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}
src/style.css
@import "tailwindcss";
src/shims-vue.d.ts
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
npmthe default on every machine
src/App.vue
<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.

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 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 dev
npmthe default on every machine

More Vue guides

All frameworks

Built by Vidhal. The source is available on GitHub.

MIT licensed