Docs / Frameworks
Vite
Add UI Loft items to a Vite + React app. Vite needs Tailwind and the @ import alias first; then every item is one command.
- Version
- React
- Needs
- Tailwind 4 + shadcn + @ alias
- Setup time
- About 5 minutes
Set up
Create the app
Skip this if you already have a React + TypeScript app.
Terminalnpm create vite@latest my-app -- --template react-ts cd my-app npm installAdd Tailwind
Tailwind's Vite plugin, and Node's types for the config below.
Terminalnpm install tailwindcss @tailwindcss/vite npm install -D @types/nodeLoad Tailwind
Replace everything in
src/index.csswith this line.src/index.css@import "tailwindcss";Add the @ alias for TypeScript
Add
pathsundercompilerOptionsin bothtsconfig.jsonandtsconfig.app.json. NobaseUrlneeded.tsconfig.json and tsconfig.app.json{ "compilerOptions": { "paths": { "@/*": ["./src/*"] } } }Add Tailwind and the alias to Vite
Replace
vite.config.tswith this.vite.config.tsimport path from "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"), }, }, })Set up shadcn
It makes a
components.jsonand fillssrc/index.csswith the theme.-dtakes the defaults.Terminalnpx shadcn@latest init -dAdd an item
Copy the command from any item page. The file lands in
src/components/.Terminalnpx shadcn@latest add https://uiloft.dev/r/glow-button.jsonUse it
Import it anywhere in your app.
src/App.tsximport { GlowButton } from "@/components/glow-button" export default function App() { return <GlowButton>Get started</GlowButton> }
Good to know
- There's no server rendering here, so shadcn leaves out
"use client". Every item runs in the browser as is. - Already have Tailwind 4 and the @ alias? Start at Set up shadcn.
- To update an item, run its command again. shadcn asks before it overwrites a file.