डॉक्स / फ़्रेमवर्क
Vite
Vite + React ऐप में UI Loft आइटम जोड़ें। Vite को पहले Tailwind और @ इम्पोर्ट alias चाहिए; फिर हर आइटम एक कमांड है।
- वर्शन
- React
- ज़रूरत
- Tailwind 4 + shadcn + @ alias
- सेटअप का समय
- करीब 5 मिनट
सेट करें
ऐप बनाएँ
अगर आपके पास पहले से React + TypeScript ऐप है तो इसे छोड़ दें।
टर्मिनलnpm create vite@latest my-app -- --template react-ts cd my-app npm installTailwind जोड़ें
Tailwind का Vite प्लगइन, और नीचे के कॉन्फ़िग के लिए Node के टाइप।
टर्मिनलnpm install tailwindcss @tailwindcss/vite npm install -D @types/nodeTailwind लोड करें
src/index.cssमें सब कुछ इस लाइन से बदल दें।src/index.css@import "tailwindcss";TypeScript के लिए @ alias जोड़ें
tsconfig.jsonऔरtsconfig.app.jsonदोनों मेंcompilerOptionsके नीचेpathsजोड़ें।baseUrlकी ज़रूरत नहीं।tsconfig.json और tsconfig.app.json{ "compilerOptions": { "paths": { "@/*": ["./src/*"] } } }Vite में Tailwind और alias जोड़ें
vite.config.tsको इससे बदल दें।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"), }, }, })shadcn सेट करें
यह
components.jsonबनाता है औरsrc/index.cssमें थीम भरता है।-dडिफ़ॉल्ट लेता है।टर्मिनलnpx shadcn@latest init -dआइटम जोड़ें
किसी भी आइटम पेज से कमांड कॉपी करें। फ़ाइल
src/components/में आती है।टर्मिनलnpx shadcn@latest add https://uiloft.dev/r/glow-button.jsonइस्तेमाल करें
इसे अपने ऐप में कहीं भी इम्पोर्ट करें।
src/App.tsximport { GlowButton } from "@/components/glow-button" export default function App() { return <GlowButton>Get started</GlowButton> }
जानने लायक
- यहाँ सर्वर रेंडरिंग नहीं है, इसलिए shadcn
"use client"छोड़ देता है। हर आइटम ब्राउज़र में जैसा है वैसा चलता है। - Tailwind 4 और @ alias पहले से हैं? shadcn सेट करने से शुरू करें।
- आइटम अपडेट करने के लिए उसकी कमांड फिर चलाएँ। फ़ाइल बदलने से पहले shadcn पूछता है।