shadcn/ui with Astro: setup, islands and the templates that use it
Published 6 min read
On this page
shadcn/ui works in Astro, and it's a better match than it first looks. Astro renders React components to plain HTML on the server and only sends JavaScript for the ones you mark as interactive, so a page full of shadcn Cards, Buttons and Badges can ship almost no JavaScript at all. This post covers how to set it up today, what to watch out for, and the Astro templates that use shadcn/ui, free and paid.
Everything here was checked on 22 November 2026 against the shadcn/ui Astro guide, the Astro docs on framework components and each template's repo or product page. We sell Astro themes built on shadcn/ui ourselves; they're in the list, marked as ours.
Install shadcn/ui in Astro#
The shadcn docs give three ways in. For a new project, the CLI can scaffold an Astro app with everything wired up:
pnpm dlx shadcn@latest init -t astroAdd --monorepo for a monorepo layout. If you'd rather pick your style, colors and fonts first, the shadcn/create page builds the same command with a --preset code for your choices.
For an existing project, you need Tailwind and the React integration first. Astro's Tailwind template gives you both:
pnpm create astro@latest astro-app -- --template with-tailwindcss --install --add react --gitThen add the @/* path alias to tsconfig.json:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}And run the usual commands:
pnpm dlx shadcn@latest init
pnpm dlx shadcn@latest add buttonMake sure your global stylesheet is imported on every page. The Tailwind template does it in src/layouts/main.astro; if you use your own layout, import @/styles/global.css there.
Two things changed in 2026 that older tutorials won't mention. New projects use Tailwind v4 and React 19, and since July 2026 shadcn init uses Base UI by default instead of Radix. (Our shadcn/ui guide compares the three foundations.) Radix isn't deprecated: pass -b radix if you want it, for example to match blocks written for Radix.
Use components as islands#
This is the part the shadcn guide leaves out. In Astro, a React component renders as static HTML unless you give it a client: directive:
---
import { Button } from '@/components/ui/button';
import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/card';
import { SignupDialog } from '@/components/signup-dialog';
---
<Card>
<CardHeader><CardTitle>Static, no JavaScript</CardTitle></CardHeader>
<CardContent>
<Button asChild><a href="/pricing/">See pricing</a></Button>
</CardContent>
</Card>
<!-- Interactive: needs JavaScript in the browser -->
<SignupDialog client:idle />A few rules that save time:
- Static components need no directive. Button (as a link), Card, Badge, Separator, Avatar and the like render fine as HTML.
- Anything that opens, closes or holds state needs one. Dialog, Sheet, DropdownMenu, Tabs, Popover, Select and Carousel do nothing without JavaScript. Use
client:visibleorclient:idleunless the component must work the instant the page loads. - Hydrate the wrapper, not each part. Astro islands don't share React context with each other. A
<Dialog>with its trigger and content written out in an.astrofile breaks, because each part would be a separate island. Put the whole dialog in one React component (likeSignupDialogabove) and hydrate that. - Functions don't cross the boundary. You can't pass an
onClickhandler or a render prop from an.astrofile to a hydrated component. Pass data, and keep the behaviour inside the React file. To pass markup in, usechildrenor named slots. - The example above uses
asChild, which is the Radix API. On the Base UI base, the same thing is written with arenderprop. Match the examples you copy to the base you installed.
Astro templates that use shadcn/ui#
| Template | Price | Licence | Astro / Tailwind | What it is | Last commit |
|---|---|---|---|---|---|
| AREA44 astro-shadcn-ui-template | Free | MIT | 7 / v4, Base UI | Bare starter | Nov 2026 |
| Fulldev UI | Free | MIT | 7 / v4 | 100+ native Astro components and blocks via the shadcn CLI | Oct 2026 |
| bejamas/ui | Free | MIT | 7 / v4 | 26+ zero-JS Astro components | Nov 2026 |
| one-ie astro-shadcn | Free | MIT | 5 / v4, Radix | Starter with a blog | Sep 2025 |
| Astronomy (astro-nomy) | Free | MIT | 4 / v3 | App demo | Jun 2024 |
| Shadcnblocks templates | Premium $299 / Elite $399 | Commercial | 7 / v4 | 21 Astro templates | Closed source |
| Shadcn Studio templates | Pro plan and up; 3 free | Commercial | 6 / v4 | 10+ Astro templates | Closed source |
| themes.dev themes | €199 for all 26 | Commercial | Astro / v4, Base UI | Complete sites by sector | Nov 2026 |
AREA44 astro-shadcn-ui-template
This starter (MIT, about 210 stars) is the only free one we found on the current default stack: Astro 7, Tailwind v4, shadcn/ui on Base UI and the v4 CLI, with dependencies kept up to date by a bot. It's a bare starting point, with no pages or blocks, which is exactly right if you want a clean setup and nothing else.
Fulldev UI
Fulldev UI (MIT, about 620 stars) takes a different route: more than 100 components and blocks written as plain Astro components with no framework dependency, installed through the shadcn CLI from its own registry. It's a component library rather than a finished site, and its README asks for Node 22.12 or later.
bejamas/ui
bejamas/ui (MIT, about 250 stars) is an Astro-native take on the shadcn idea: 26+ components as .astro files, zero JavaScript by default, using the shadcn registry format. It's not shadcn/ui itself, it has its own CLI, and it's still before version 1.0.
one-ie astro-shadcn
This starter (MIT) bundles shadcn/ui on Radix with a blog (search, tags, table of contents), RSS and a sitemap. It's on Astro 5 and was last updated in September 2025.
Astronomy
astro-nomy (MIT, about 500 stars) is the most-starred Astro and shadcn project, a demo app with auth, docs and a blog. Its README says it can't yet be considered a starter template, and it's on Astro 4, Tailwind v3 and React 18, last updated in June 2024. Good for reading, not for starting from.
Shadcnblocks Astro templates
Shadcnblocks sells 21 templates in Astro (Astro 7, Tailwind v4), each also available in Next.js. They come with the Premium ($299) and Elite ($399) plans, one-time for one person; a 40% Black Friday discount was running when we looked. No resale, and refunds on digital goods are generally not offered.
Shadcn Studio Astro templates
Shadcn Studio has more than ten Astro templates; its listing on astro.build names Ink, Track and Bistro as free. Its docs say the paid templates come with the Pro, Team and Enterprise plans rather than being sold one by one. The free tier's licence is MIT plus the Commons Clause.
themes.dev website themes
Our own entry. UI Pro includes 26 complete website themes in Astro, each for a sector: software, agencies, developer tools, health practices, restaurants and twenty more. They're being rebuilt from our shadcn/ui blocks (React on Base UI, Tailwind v4). Ledger, for example, renders every section to static HTML in Astro; the header's menus are the only client-side JavaScript, and the pricing switch works without it.
Price: €199 one-time for one person (excluding VAT), for all 26 themes plus 560 blocks, 169 app screens and 14 page templates. UI Pro Complete (€299) adds a Next.js + Sanity edition of every theme. Each theme comes as a private GitHub repository. Watch out: there's no free theme, and if you only want one site, a single template elsewhere may cost less. Start at our shadcn themes for Astro, the theme library or the Astro SaaS landing page.
Astro or Next.js for a shadcn site?#
Use Astro when the site is mostly content that people read: marketing pages, docs, a blog, a portfolio. You get static HTML by default, fast pages and React only where it's needed. Use Next.js when the site and the app are the same codebase, or when most pages need to be interactive or personalised. Many teams do both: the app in Next.js, the marketing site in Astro, sharing one set of shadcn components and design tokens.
If you want sections to drop into an Astro page, see the shadcn block libraries compared or browse our blocks.
FAQ#
Does shadcn/ui work with Astro?
Yes. Install the React integration and Tailwind, run shadcn init, and import components into .astro files. They render as static HTML; add a client: directive to the ones that need interaction, such as dialogs, menus and tabs. The shadcn CLI can also scaffold a new Astro project with shadcn init -t astro.
Why doesn't my shadcn dialog open in Astro?
Either the component has no client: directive, so no JavaScript was sent, or its parts are written out in an .astro file, so each part became its own island and they can't share state. Put the whole dialog in one React component and render that with client:idle or client:load.
Can I use shadcn/ui in Astro without React?
Not shadcn/ui itself: its components are React. Projects like Fulldev UI and bejamas/ui offer shadcn-style components written as native Astro components, installed with a CLI, that need no React at all.

