Skip to content

one-ie/astro-shadcn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

119 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Astro 5 + Shadcn/UI + Tailwind v4 Starter Kit

A production-ready, enterprise-grade starter template combining Astro's performance with Shadcn's beautiful components and Tailwind CSS v4's modern CSS-based configuration. Featuring advanced blog system, search, accessibility, and SEO optimizations.

✨ What's Inside

  • Astro 5.14+ - Lightning-fast static site generation
  • React 19 - Latest React with improved performance
  • Tailwind CSS v4 - Modern CSS-based configuration with HSL colors
  • Shadcn/UI - Complete component library (50+ components)
  • TypeScript 5.9+ - Full type safety with strict mode
  • Dark Mode - Beautiful theme switching with no FOUC
  • Blog System - Full-featured with search, tags, categories, ToC
  • SEO Optimized - Sitemap, RSS feed, OG tags, canonical URLs
  • Accessibility - WCAG 2.1 AA compliant with keyboard navigation
  • 100/100 Lighthouse - Perfect performance scores

🎨 Screenshots

Astro Shadcn UI

⚑ Quick Start

# Clone the repository
git clone https://github.com/one-ie/astro-shadcn.git

# Navigate to project
cd astro-shadcn

# Install dependencies (using pnpm recommended)
pnpm install

# Start development server
pnpm dev

# Or with npm
npm install
npm run dev

Visit http://localhost:4321 - You're ready to go! πŸŽ‰

🎯 Key Features

πŸ“ Advanced Blog System

  • Content Collections - Type-safe blog posts with Zod validation
  • Multi-view Layouts - List, 2-column, 3-column, and 4-column grid views
  • Real-time Search - Instant filtering by title and description
  • Rich Metadata - Tags, categories, author, featured posts, reading time
  • Table of Contents - Auto-generated with IntersectionObserver tracking
  • Social Sharing - Native Web Share API + social media buttons
  • RSS Feed - Auto-generated at /rss.xml

πŸ” SEO & Performance

  • Meta Tags - Open Graph, Twitter Cards, canonical URLs
  • Sitemap - Auto-generated with @astrojs/sitemap
  • Image Optimization - Astro's built-in Image component with lazy loading
  • Minimal JavaScript - Only interactive components hydrate
  • Perfect Scores - 100/100 Lighthouse across all metrics

β™Ώ Accessibility Features

  • Skip to Content - Keyboard-accessible skip link
  • ARIA Labels - Proper semantic markup throughout
  • Focus Indicators - Visible focus states on all interactive elements
  • Screen Reader Support - Tested with VoiceOver and NVDA
  • Keyboard Navigation - Fully navigable without a mouse

πŸ› οΈ Developer Experience

  • ESLint & Prettier - Pre-configured code formatting
  • VS Code Settings - Optimized workspace configuration
  • Path Aliases - Clean imports with @/ prefix
  • Type Safety - Strict TypeScript with no implicit any
  • Hot Reload - Fast refresh during development

🎨 Pre-installed Components

All Shadcn/UI components are pre-configured for Astro with 50+ components ready to use:

---
// Example usage in .astro file
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
---

<Button client:load>Click me!</Button>

Available Components (50+)

Layout & Navigation:

  • βœ… Sidebar, Navigation Menu, Breadcrumb, Tabs

Forms & Inputs:

  • βœ… Button, Input, Textarea, Select, Checkbox, Radio Group, Switch, Slider, Calendar, Date Picker, Input OTP

Data Display:

  • βœ… Card, Table, Badge, Avatar, Progress, Chart (Recharts), Carousel

Feedback & Overlays:

  • βœ… Dialog, Alert Dialog, Sheet, Drawer, Popover, Tooltip, Toast, Sonner, Alert

Interactive:

  • βœ… Accordion, Collapsible, Dropdown Menu, Context Menu, Menubar, Hover Card, Command, Resizable Panels

Custom Components:

  • βœ… BlogSearch - Real-time blog post filtering
  • βœ… TableOfContents - Auto-generated with active tracking
  • βœ… ShareButtons - Native + social media sharing
  • βœ… ErrorBoundary - React error boundary with alerts
  • βœ… ModeToggle - Theme switcher component

πŸ› οΈ Project Structure

astro-shadcn/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ ui/              # 50+ Shadcn components
β”‚   β”‚   β”œβ”€β”€ BlogSearch.tsx   # Real-time blog search
β”‚   β”‚   β”œβ”€β”€ TableOfContents.tsx
β”‚   β”‚   β”œβ”€β”€ ShareButtons.tsx
β”‚   β”‚   β”œβ”€β”€ ErrorBoundary.tsx
β”‚   β”‚   β”œβ”€β”€ ModeToggle.tsx   # Theme switcher
β”‚   β”‚   └── Sidebar.tsx      # Expandable navigation
β”‚   β”œβ”€β”€ layouts/
β”‚   β”‚   β”œβ”€β”€ Layout.astro     # Base layout with SEO
β”‚   β”‚   └── Blog.astro       # Blog post layout with ToC
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ index.astro      # Homepage
β”‚   β”‚   β”œβ”€β”€ blog/
β”‚   β”‚   β”‚   β”œβ”€β”€ index.astro  # Blog index with search
β”‚   β”‚   β”‚   └── [...slug].astro # Dynamic blog posts
β”‚   β”‚   β”œβ”€β”€ rss.xml.ts       # RSS feed generator
β”‚   β”‚   └── 404.astro        # Custom 404 page
β”‚   β”œβ”€β”€ content/
β”‚   β”‚   β”œβ”€β”€ config.ts        # Content collections schema
β”‚   β”‚   └── blog/            # Blog posts in markdown
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ utils.ts         # cn() utility for Tailwind
β”‚   β”‚   └── reading-time.ts  # Reading time calculator
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── site.ts          # Site configuration
β”‚   └── styles/
β”‚       └── global.css       # Tailwind v4 with @theme blocks
β”œβ”€β”€ .vscode/
β”‚   β”œβ”€β”€ settings.json        # Workspace settings
β”‚   └── extensions.json      # Recommended extensions
β”œβ”€β”€ astro.config.mjs         # Astro + sitemap config
β”œβ”€β”€ components.json          # Shadcn/ui configuration
β”œβ”€β”€ .eslintrc.json           # ESLint configuration
β”œβ”€β”€ .prettierrc              # Prettier configuration
β”œβ”€β”€ tsconfig.json            # TypeScript with path aliases
└── CLAUDE.md                # AI assistant instructions

Using Components

---
// src/pages/index.astro
import { Button } from '@/components/ui/button';
import { Card, CardHeader, CardTitle } from '@/components/ui/card';
---

<Card>
  <CardHeader>
    <CardTitle>Welcome to Astro + Shadcn!</CardTitle>
  </CardHeader>
  <Button client:load>Interactive Button</Button>
</Card>

πŸš€ Development Workflow

Commands

# Development
pnpm dev              # Start dev server
pnpm build            # Build for production
pnpm preview          # Preview production build

# Code Quality
pnpm lint             # Lint code with ESLint
pnpm format           # Format with Prettier

# Type Checking
npx astro check       # TypeScript type checking
npx astro sync        # Sync content collection types

Adding Blog Posts

Create a new markdown file in src/content/blog/:

---
title: 'Your Post Title'
description: 'A brief description'
date: 2025-01-15
author: 'Your Name'
tags: ['astro', 'react', 'tailwind']
category: 'tutorial'
featured: true
image: '/path/to/image.jpg'
---

Your content here with full markdown support!

## Headings auto-generate Table of Contents

Content is automatically indexed for search.

Using React Components in Astro

---
// Always add client:load for interactive components
import { Dialog } from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
---

<!-- Interactive component needs client:load -->
<Dialog client:load>
  <Button client:load>Click me!</Button>
</Dialog>

<!-- Static components don't need hydration -->
<Card>
  <CardHeader>
    <CardTitle>Static Card</CardTitle>
  </CardHeader>
</Card>

Customizing Theme

Edit src/styles/global.css to customize colors:

@theme {
  --color-primary: 0 0% 9%;
  --color-background: 0 0% 100%;
  /* Add your custom colors */
}

/* Dark mode overrides */
.dark {
  --color-background: 0 0% 3.9%;
  --color-foreground: 0 0% 98%;
}

πŸ” Troubleshooting

Common Issues & Solutions

Type Errors After Adding Content

npx astro sync  # Regenerate content collection types

Component Not Interactive

<!-- Add client:load directive -->
<Button client:load>Click me</Button>

Styling Issues

<!-- Use className (not class) in React components -->
<Button className="custom-class">Button</Button>

<!-- Use class in Astro files -->
<div class="custom-class">Content</div>

Build Failures

npx astro check  # Check for TypeScript errors
pnpm lint        # Check for linting errors

πŸ’‘ Pro Tips

  1. Component Usage in Astro

    ---
    // Always import in the frontmatter
    import { Button } from '@/components/ui/button';
    ---
    
    <!-- Use in template -->
    <Button client:load>Click me!</Button>
  2. Styling with Tailwind v4

    <!-- Use semantic color names that work in both light and dark modes -->
    <div class="bg-background text-foreground border border-border">
      <Button class="m-4">Styled Button</Button>
    </div>
  3. Layout Usage

    ---
    import Layout from '../layouts/Layout.astro';
    ---
    
    <Layout title="Home">
      <!-- Your content -->
    </Layout>

πŸ“Š Performance & Screenshots

⚑ Lighthouse Scores

Desktop Performance

Perfect scores across all metrics:

  • πŸš€ Performance: 100
  • β™Ώ Accessibility: 100
  • πŸ”§ Best Practices: 100
  • πŸ” SEO: 100

What Makes It Fast?

  • Islands Architecture - Only interactive components hydrate
  • Image Optimization - Automatic WebP conversion and lazy loading
  • Minimal JavaScript - ~30KB gzipped for the entire site
  • CSS-First - Tailwind v4 with zero runtime overhead
  • Static Generation - Pre-rendered pages for instant loads
  • Smart Bundling - Code splitting and tree shaking enabled

πŸ“š Documentation & Resources

Official Docs

Project Docs

  • CLAUDE.md - AI assistant instructions and architecture guide
  • improve.md - Detailed improvement roadmap and best practices

🀝 Contributing & Support

πŸ“¦ What's New

Latest Updates

  • βœ… Blog Search - Real-time filtering by title/description
  • βœ… Table of Contents - Auto-generated with active tracking
  • βœ… Social Sharing - Native Web Share API + social buttons
  • βœ… Enhanced Schema - Tags, categories, author, reading time
  • βœ… SEO Optimized - Sitemap, RSS, OG tags, canonical URLs
  • βœ… Accessibility - WCAG 2.1 AA compliant
  • βœ… Developer Tools - ESLint, Prettier, VS Code settings
  • βœ… Error Handling - 404 page + React error boundaries

🎯 Use Cases

Perfect for:

  • πŸ“ Technical blogs and documentation sites
  • 🎨 Portfolio and personal websites
  • πŸš€ Landing pages and marketing sites
  • πŸ“Š Dashboards and admin panels
  • πŸ›οΈ E-commerce frontends
  • πŸ“± Progressive Web Apps

Built with πŸš€ Astro 5, ⚑ Tailwind v4, βš›οΈ React 19, and 🎨 Shadcn/UI by ONE

License: MIT

About

Build beautiful websites with Astro 5, shadcn/ui and React

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors