Astro
Install shadcn/ui in Astro with the official CLI. React + Tailwind islands, then add a component from the shadcn.io registry.
init -t astro scaffolds the app. For an existing site: the with-tailwindcss template (or add React + Tailwind yourself), @/* → ./src/*, then init.
Use the CLI
Create the project
npx shadcn@latest init -t astroMonorepo:
npx shadcn@latest init -t astro --monorepoAdd a component
npx shadcn@latest add https://www.shadcn.io/r/card.jsonMonorepo: from apps/web, or -c apps/web from the root.
Import it
---
import Layout from "@/layouts/main.astro"
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
---
<Layout>
<Card className="max-w-sm">
<CardHeader>
<CardTitle>Project Overview</CardTitle>
<CardDescription>
Track progress and recent activity for your Astro app.
</CardDescription>
</CardHeader>
<CardContent>
Your design system is ready. Start building your next component.
</CardContent>
</Card>
</Layout>Monorepo: apps/web/src/pages/index.astro, import @workspace/ui/components/card. apps/web/src/layouts/main.astro already imports @workspace/ui/globals.css.
Existing project
Create the app if you need one
npm create astro@latest astro-app -- --template with-tailwindcss --install --add react --gitThat template loads CSS from src/layouts/main.astro. Keep the layout, or import @/styles/global.css on the page.
tsconfig.json
Skip if @/* is already there.
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}Run init
npx shadcn@latest initAdd a component
npx shadcn@latest add https://www.shadcn.io/r/button.json---
import Layout from "@/layouts/main.astro"
import { Button } from "@/components/ui/button"
---
<Layout>
<div class="grid h-screen place-items-center content-center">
<Button>Button</Button>
</div>
</Layout>React has to be an integration
npx astro add react if the template did not. shadcn components are React. Astro pages import them in the frontmatter.
Questions
Related
Was this page helpful?
Sign in to leave feedback.
Remix
Install shadcn/ui in Remix with the official CLI. create-remix, then init, then add a component from the shadcn.io registry. Imports use ~/.
TanStack Start
Install shadcn/ui in TanStack Start with the official CLI. File routes, then add a component from the shadcn.io registry. TypeScript and Tailwind CSS.