Installation
Vite
Set up Aback UI in a Vite React TypeScript app. Verified with the react-ts template on Vite 8, React 19, and Tailwind CSS v4.
Create the app
npx create-vite@latest my-app --template react-tsThen
cd my-appand install dependencies with your package manager.Add Tailwind CSS
npm install tailwindcss @tailwindcss/viteReplace everything in
src/index.csswith the Tailwind import. The template's starter styles would otherwise fight the Aback theme:src/index.csscss @import "tailwindcss";Add the @/ alias
Installed components import
@/components/uiand@/lib/utils, so the alias has to resolve in three places. The template splits TypeScript settings across files: addpathstotsconfig.json, which the CLI and editors read, and totsconfig.app.json, which the build type-checks with.tsconfig.jsonjson { "files": [], "references": [ { "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" } ], "compilerOptions": { "paths": { "@/*": ["./src/*"] } } }tsconfig.app.jsonjson { "compilerOptions": { // ...keep the template's options "paths": { "@/*": ["./src/*"] } } }Then teach Vite the same alias and add the Tailwind plugin:
npm install -D @types/nodevite.config.tsts 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(import.meta.dirname, "./src"), }, }, });Run init
npx aback-ui@latest initinit detects Vite, finds
src/index.css, and adds the theme import after Tailwind. It writessrc/lib/utils.ts,styles/aback.css, andaback-ui.json, and installsclsxandtailwind-merge.src/index.csscss @import "tailwindcss"; @import "../styles/aback.css";Add components
npx aback-ui@latest add button dialogsrc/App.tsxtsx import { Button } from "@/components/ui/button"; export default function App() { return <Button>Save changes</Button>; }Run
npm run buildto confirm the alias resolves in both TypeScript and Vite.
npx aback-ui@latest add theme-toggleA Vite app has no server-rendered layout, so apply the saved theme with an inline script in index.html, before your bundle loads. It is the same code ThemeScript renders, reading the default theme storage key that ThemeToggle writes:
<head>
<!-- ...the template's tags -->
<script>
(function(){try{var t=localStorage.getItem("theme");var d=t==="dark"||((!t||t==="system")&&window.matchMedia("(prefers-color-scheme: dark)").matches);document.documentElement.classList.toggle("dark",d);}catch(e){}})();
</script>
</head>Then render <ThemeToggle /> wherever you want the switch. The dark mode guide covers useTheme and custom labels.