### Clone and Run Astro Template
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/README.md
Clone the repository, install dependencies, and start the development server.
```bash
git clone https://github.com/area44/astro-shadcn-ui-template
cd astro-shadcn-ui-template
pnpm install
pnpm dev
```
--------------------------------
### Import Alias Example
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/00-START-HERE.txt
Use the '@/' prefix for all imports to reference components and utilities within the project.
```text
Use @/ prefix for all imports
Example: import { Button } from "@/components/ui/button"
```
--------------------------------
### Complete Product Card Example
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/api-reference-ui-card.md
A comprehensive example demonstrating a product card with an image, header, content, and footer. This showcases the integration of CardFooter within a larger UI component.
```tsx
import {
Card,
CardHeader,
CardTitle,
CardDescription,
CardAction,
CardContent,
CardFooter,
} from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Field, FieldLabel } from "@/components/ui/field";
export function ProductCard({ product }) {
return (
{product.name}${product.price}
{product.description}
);
}
```
--------------------------------
### Astro Configuration Example
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/overview.md
Example Astro configuration file (`astro.config.ts`) demonstrating integration with React and Tailwind CSS, and site URL/base path configuration.
```typescript
import { defineConfig } from "astro/config";
import react from "@astrojs/react";
import tailwind from "@tailwindcss/vite";
// https://astro.build/config
export default defineConfig({
integrations: [react()],
vite: {
plugins: [tailwind()]
},
site: process.env.VERCEL ? `https://${process.env.VERCEL_URL}` : process.env.SITE,
base: process.env.BASE
});
```
--------------------------------
### Basic Confirmation Dialog Example
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/api-reference-ui-dialogs.md
Demonstrates a basic AlertDialog for user confirmation before an action.
```tsx
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogMedia,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
import { TrashIcon, AlertCircleIcon } from "lucide-react";
// Basic confirmation dialog
}>
Delete Item
Are you sure?
This action cannot be undone. This will permanently delete the item.
CancelDelete
```
--------------------------------
### File Input
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/api-reference-ui-basic.md
Example of using the Input component for file uploads.
```tsx
import { Input } from "@/components/ui/input";
// File input
```
--------------------------------
### Development Commands
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/README.md
Run these commands to manage the development lifecycle of the project, including starting the server, building, previewing, formatting, and linting.
```bash
pnpm dev
```
```bash
pnpm build
```
```bash
pnpm preview
```
```bash
pnpm fmt
```
```bash
pnpm lint
```
```bash
pnpm check
```
--------------------------------
### Basic Select Example
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/api-reference-ui-forms.md
Demonstrates a basic Select component with string options. Ensure the 'items' prop is provided with an array of strings.
```tsx
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
// Basic select
```
--------------------------------
### shadcn/ui Configuration Example
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/overview.md
shadcn/ui configuration file (`components.json`) specifying UI style, icon library, Tailwind CSS settings, and component import aliases.
```json
{
"$schema": "https://ui.shadcn.com/schemas/config.json",
"style": "base-vega",
"tailwind": {
"config": "tailwind.config.ts",
"css": "src/styles/globals.css",
"baseColor": "zinc",
"cssVariables": true
},
"imageLibrary": "@/components/ui/image",
"icons": "lucide-react",
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
}
}
```
--------------------------------
### Controlled Popover Example
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/api-reference-ui-dialogs.md
Illustrates how to control the Popover's open state programmatically using the 'open' and 'onOpenChange' props.
```tsx
const [open, setOpen] = useState(false);
}>
Toggle Popover
Popover content
```
--------------------------------
### Render ComponentExample
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/api-reference-layout.md
Display the ComponentExample component within a React page. This component demonstrates Card and Form examples.
```tsx
import { ComponentExample } from "@/components/ComponentExample";
// Display component examples
export default function Page() {
return ;
}
```
--------------------------------
### TypeScript Configuration Example
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/overview.md
TypeScript configuration file (`tsconfig.json`) extending Astro's strict configuration and defining a path alias for source files.
```json
{
"extends": "astro/tsconfigs/strict",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
}
}
```
--------------------------------
### Basic Vertical Field Example
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/api-reference-ui-forms.md
Demonstrates the basic usage of the Field component in a vertical layout with a label, input, and description.
```tsx
Email AddressWe'll never share your email.
```
--------------------------------
### Basic Combobox Example
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/api-reference-ui-forms.md
A simple Combobox with a searchable input and a list of items. Use this for single-select scenarios where filtering is needed.
```tsx
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox";
const frameworks = ["React", "Vue", "Svelte", "Astro", "Next.js"];
// Basic combobox
No frameworks found
{(item) => (
{item}
)}
```
--------------------------------
### Button Component
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/api-reference-ui-basic.md
Documentation for the flexible Button component, detailing its parameters, variants, sizes, and usage examples.
```APIDOC
## Button Component
### Description
A flexible button component with multiple variants and sizes, built on Base UI primitives. It allows for customization of style, size, and behavior.
### Method
React Component
### Parameters
#### Component Props
- **variant** (string) - Optional - Default: "default" - Button style variant. Options: "default", "outline", "secondary", "ghost", "destructive", "link".
- **size** (string) - Optional - Default: "default" - Button size variant. Options: "default", "xs", "sm", "lg", "icon", "icon-xs", "icon-sm", "icon-lg".
- **className** (string) - Optional - Additional Tailwind CSS classes.
- **...props** (ButtonPrimitive.Props) - Optional - All HTML button element props.
### Variant Styles
- **default**: Solid primary color background.
- **outline**: Bordered style with transparent background.
- **secondary**: Solid secondary color background.
- **ghost**: Transparent background, hover highlight.
- **destructive**: Red/danger styled button.
- **link**: Text-only link style with underline on hover.
### Size Variants
- **default**: h-9, px-2.5 - Standard button.
- **xs**: h-6, px-2 - Small text button.
- **sm**: h-8, px-2.5 - Small button.
- **lg**: h-10, px-2.5 - Large button.
- **icon**: 36x36px - Icon-only buttons.
- **icon-xs**: 24x24px - Small icon buttons.
- **icon-sm**: 32x32px - Medium icon buttons.
- **icon-lg**: 40x40px - Large icon buttons.
### Request Example
```tsx
import { Button } from "@/components/ui/button";
// Default primary button
// Different variants
// Different sizes
// With custom classes
// Disabled state
// In forms
// With loading state (custom implementation)
```
### Accessibility
- Automatically handles focus states with ring-ring color.
- Supports aria-* attributes.
- Invalid state styling with aria-invalid.
- Disabled state with proper cursor and opacity.
### Import Path
```typescript
import { Button, buttonVariants } from "@/components/ui/button";
```
```
--------------------------------
### Badge Component Usage Examples
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/api-reference-ui-basic.md
Demonstrates various ways to use the Badge component, including different variants, with icons, conditional rendering, and in multiple instances.
```tsx
import { Badge } from "@/components/ui/badge";
// Basic badge
Default
```
```tsx
// Different variants
SecondaryAlertOutlineGhostLink
```
```tsx
// With icons
Success
```
```tsx
// Status indicators
{status}
```
```tsx
// Multiple badges
DesignFrontendReact
```
```tsx
// In card headers
FeatureNew
```
--------------------------------
### MainNav Component Usage
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/api-reference-layout.md
Example of how to use the MainNav component in a header. It can be styled with additional Tailwind CSS classes.
```tsx
import { MainNav } from "@/components/MainNav";
// In header
// With custom styling
```
--------------------------------
### Create a Complete Page Layout
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/EXAMPLES.md
Provides a full-page example integrating Header, Footer, and ComponentExample components within a main content area. This structure ensures a min-height of the screen and includes a container for centered content with padding.
```tsx
import { Header } from "@/components/Header";
import { Footer } from "@/components/Footer";
import { ComponentExample } from "@/components/ComponentExample";
export default function HomePage() {
return (
Welcome
Explore our component library and examples.
);
}
```
--------------------------------
### Example Usage of ThemeToggle
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/api-reference-layout.md
Demonstrates how to import and use the ThemeToggle component within a React application, typically in a header or navigation area.
```tsx
import { ThemeToggle } from "@/components/ThemeToggle";
// In header
// Usage within layout
export default function Layout({ children }) {
return (
<>
{children}
>
);
}
```
--------------------------------
### Settings Dialog with Tabs
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/EXAMPLES.md
Implement a settings dialog using cards, fields, and inputs. This example shows how to manage form state for various settings like email, theme, and notifications.
```tsx
import { useState } from "react";
import { Button } from "@/components/ui/button";
import { Card, CardHeader, CardTitle, CardContent, CardFooter } from "@/components/ui/card";
import { Field, FieldLabel, FieldDescription } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
export function SettingsDialog() {
const [settings, setSettings] = useState({
email: "",
theme: "light",
notifications: true,
});
const handleSave = () => {
console.log("Settings saved:", settings);
};
return (
SettingsEmail
setSettings({ ...settings, email: e.target.value })}
/>
Your email addressTheme
);
}
```
--------------------------------
### Button Component Example Usage
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/api-reference-ui-basic.md
Demonstrates various ways to use the Button component, including different variants, sizes, custom classes, disabled states, and form integration.
```tsx
import { Button } from "@/components/ui/button";
// Default primary button
// Different variants
// Different sizes
// With custom classes
// Disabled state
// In forms
// With loading state (custom implementation)
```
--------------------------------
### Horizontal Field Layout Example
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/api-reference-ui-forms.md
Shows how to configure the Field component for a horizontal layout, suitable for checkboxes or inline elements.
```tsx
Subscribe to newsletter
```
--------------------------------
### Input with Label and Form Layout
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/api-reference-ui-basic.md
Example of integrating the Input component within a form, including a label and required attribute.
```tsx
import { Input } from "@/components/ui/input";
// With label and form layout
```
--------------------------------
### Card Component Size
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/types.md
Defines the available sizes for the Card component. Usage example shows how to apply a size prop.
```typescript
type CardSize = "default" | "sm";
```
```typescript
import { Card } from "@/components/ui/card";
{/* card content */}
```
--------------------------------
### Development Commands
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/00-START-HERE.txt
Common development commands for managing the Astro project, including starting the dev server, building for production, formatting, linting, and type checking.
```text
pnpm dev - Start development server
pnpm build - Build for production
pnpm fmt - Format code
pnpm lint - Lint code
pnpm check - Lint and format
```
--------------------------------
### Label Component Examples
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/api-reference-ui-basic.md
Demonstrates various ways to use the Label component, from basic association with form controls to custom styling and handling disabled states. It also shows integration with checkboxes and radio buttons.
```tsx
import { Label } from "@/components/ui/label";
// Basic label with input
// With custom styling
// Disabled state (applied via group data)
// With checkbox or radio
```
--------------------------------
### Separator Component Example Usage
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/api-reference-ui-basic.md
Demonstrates various ways to use the Separator component, including horizontal, vertical, within containers, navigation, and cards.
```tsx
import { Separator } from "@/components/ui/separator";
// Horizontal separator (default)
// Vertical separator
// In a container
Section 1
Section 2
// Between navigation items
// In card with custom styling
TitleContent
```
--------------------------------
### Input Group Addon Alignment
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/types.md
Defines the alignment options for InputGroupAddon. Usage example shows setting the align prop.
```typescript
type InputGroupAddonAlign = "inline-start" | "inline-end" | "block-start" | "block-end";
```
```typescript
import { InputGroupAddon } from "@/components/ui/input-group";
{/* addon content */}
```
--------------------------------
### Badge Component Variants
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/types.md
Defines the possible variants for the Badge component. Usage example demonstrates how to apply a specific variant to a Badge.
```typescript
type BadgeVariants = {
variant?: "default" | "secondary" | "destructive" | "outline" | "ghost" | "link";
};
```
```typescript
import { Badge } from "@/components/ui/badge";
Tag
```
--------------------------------
### Textarea Component Examples
Source: https://github.com/area44/astro-shadcn-ui-template/blob/main/_autodocs/api-reference-ui-basic.md
Illustrates different use cases for the Textarea component, including basic usage, controlled values, custom height, disabled states, and error handling. It also shows how to integrate it within a form.
```tsx
import { Textarea } from "@/components/ui/textarea";
// Basic textarea
// With controlled value
const [message, setMessage] = useState("");