सीधे कंटेंट पर जाएँ
भाषा22
मेनू

डॉक्स / फ़्रेमवर्क

Astro

Astro साइट में UI Loft आइटम जोड़ें। Astro में पहले React और Tailwind जोड़ने पड़ते हैं, और हिलने वाले आइटम को क्लाइंट डायरेक्टिव चाहिए।

वर्शन
React
ज़रूरत
React + Tailwind 4 + shadcn
सेटअप का समय
करीब 5 मिनट

सेट करें

  1. साइट बनाएँ

    अगर आपके पास पहले से है तो इसे छोड़ दें।

    टर्मिनल
    npm create astro@latest my-site -- --template minimal --install --no-git --yes
    cd my-site
  2. React और Tailwind जोड़ें

    Astro की अपनी कमांड दोनों इंस्टॉल करती है और astro.config.mjs अपडेट करती है। यह src/styles/global.css भी बनाती है।

    टर्मिनल
    npx astro add react tailwind --yes
  3. @ alias जोड़ें

    tsconfig.json में compilerOptions के नीचे paths जोड़ें।

    tsconfig.json
    {
      "compilerOptions": {
        "paths": {
          "@/*": ["./src/*"]
        }
      }
    }
  4. shadcn सेट करें

    यह components.json बनाता है और src/styles/global.css में थीम भरता है। -d डिफ़ॉल्ट लेता है।

    टर्मिनल
    npx shadcn@latest init -d
  5. आइटम जोड़ें

    किसी भी आइटम पेज से कमांड कॉपी करें। फ़ाइल src/components/ में आती है।

    टर्मिनल
    npx shadcn@latest add https://uiloft.dev/r/glow-button.json
  6. इस्तेमाल करें

    स्टाइल और आइटम एक बार इम्पोर्ट करें, फिर आइटम को client:load दें ताकि वह ब्राउज़र में चले।

    src/pages/index.astro
    ---
    import "@/styles/global.css"
    import { GlowButton } from "@/components/glow-button"
    ---
    
    <html lang="en">
      <body>
        <GlowButton client:load>Get started</GlowButton>
      </body>
    </html>

जानने लायक

  • क्लाइंट डायरेक्टिव के बिना Astro आइटम को सादे HTML के रूप में भेजता है: वह दिखता है, पर हिलता या प्रतिक्रिया नहीं देता।
  • client:load की जगह client:visible आइटम के स्क्रॉल करके दिखने तक रुकता है।
  • लेआउट हो तो @/styles/global.css को हर पेज में नहीं, वहाँ एक बार इम्पोर्ट करें।

दूसरे फ़्रेमवर्क