{
variant?: 'primary' | 'secondary' | 'outline'
size?: 'sm' | 'md' | 'lg'
children: React.ReactNode
}
export function Button({
variant = 'primary',
size = 'md',
children,
className = '',
...props
}: ButtonProps) {
const variants = {
primary: 'bg-blue-600 text-white hover:bg-blue-700',
secondary: 'bg-gray-600 text-white hover:bg-gray-700',
outline: 'border-2 border-blue-600 text-blue-600 hover:bg-blue-50'
}
const sizes = {
sm: 'px-3 py-1.5 text-sm',
md: 'px-4 py-2 text-base',
lg: 'px-6 py-3 text-lg'
}
const buttonClasses = `font-semibold rounded-lg transition ${variants[variant]} ${sizes[size]} ${className}`
return (
{children}
)
}
```
**Usage in app/page.tsx:**
```typescript
import { Button } from '@/components/ui/Button'
export default function Home() {
return (
Get Started
)
}
```
### 4. Apply Responsive Design
Use TailwindCSS breakpoints:
- `sm:` (640px), `md:` (768px), `lg:` (1024px), `xl:` (1280px), `2xl:` (1536px)
**NuxtJS (Vue) Responsive Grid Example:**
```vue
```
**Next.js (React) Responsive Grid Example:**
```typescript
import { Card } from '@/components/ui/Card'
export default function FeaturesSection() {
const items = [
{ id: 1, title: 'Feature 1', description: '...' },
// ...
]
return (
{items.map((item) => (
))}
)
}
```
### 5. Add Interactivity
**NuxtJS (Vue) Composable Pattern (composables/useModal.ts):**
```typescript
// Auto-imported by Nuxt - no need to import 'ref'
export function useModal() {
const isOpen = ref(false)
const open = () => { isOpen.value = true }
const close = () => { isOpen.value = false }
return { isOpen, open, close }
}
```
**Usage in any Vue component:**
```vue
```
**Next.js (React) Custom Hook Pattern (lib/hooks/useModal.ts):**
```typescript
import { useState } from 'react'
export function useModal() {
const [isOpen, setIsOpen] = useState(false)
const open = () => setIsOpen(true)
const close = () => setIsOpen(false)
return { isOpen, open, close }
}
```
**Usage in any React component:**
```typescript
'use client' // Mark as Client Component for interactivity
import { useModal } from '@/lib/hooks/useModal'
export default function MyComponent() {
const { isOpen, open, close } = useModal()
return (
Open Modal
{isOpen && }
)
}
```
### 6. Build for Production
**NuxtJS:**
```bash
npm run build # Build for production (.output/)
npm run preview # Preview production build
npm run generate # Generate static site (SSG)
```
**Next.js:**
```bash
npm run build # Build for production (.next/)
npm run start # Start production server (SSR)
# For static export (SSG), add to next.config.js:
# output: 'export'
```
## Common Patterns
### Landing Page (NuxtJS)
**Create layout (layouts/default.vue):**
```vue
```
**Create page (pages/index.vue):**
```vue
```
### Landing Page (Next.js)
**Create layout (app/layout.tsx):**
```typescript
import { Header } from '@/components/layout/Header'
import { Footer } from '@/components/layout/Footer'
import './globals.css'
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
{children}
)
}
```
**Create page (app/page.tsx):**
```typescript
import { Hero } from '@/components/sections/Hero'
import { Features } from '@/components/sections/Features'
export default function Home() {
return (
)
}
```
### Dashboard Layout (NuxtJS)
**Create dashboard layout (layouts/dashboard.vue):**
```vue
```
**Use in page (pages/dashboard/index.vue):**
```vue
```
### Dashboard Layout (Next.js)
**Create dashboard layout (app/dashboard/layout.tsx):**
```typescript
import { Sidebar } from '@/components/layout/Sidebar'
import { TopBar } from '@/components/layout/TopBar'
export default function DashboardLayout({
children,
}: {
children: React.ReactNode
}) {
return (
)
}
```
**Use in page (app/dashboard/page.tsx):**
```typescript
export default function DashboardPage() {
return (
{/* Dashboard content */}
)
}
```
## Design System
### Colors
- Primary: `blue-600`, Secondary: `gray-600`
- Success: `green-600`, Warning: `yellow-600`, Error: `red-600`
- Neutral: `gray-100` to `gray-900`
### Spacing
Use consistent scale: `p-1` (4px), `p-2` (8px), `p-4` (16px), `p-6` (24px), `p-8` (32px)
### Typography
- Headings: `text-4xl`, `text-3xl`, `text-2xl`, `text-xl`
- Body: `text-base` (16px)
- Weights: `font-normal`, `font-medium`, `font-semibold`, `font-bold`
## Advanced Guides
For detailed implementations:
- **[Component Library](references/component-library.md)** - Complete reusable Vue components with TypeScript
- **[TailwindCSS v4 Patterns](references/tailwind-patterns.md)** - Advanced styling (works with both frameworks)
- **[NuxtJS Composables](references/composition-api.md)** - State management and auto-imports (Vue-specific)
- **[React Hooks](references/react-hooks.md)** - Custom hooks and state management (React-specific)
- **[Animations](references/animations.md)** - Vue transitions and TailwindCSS animations
- **[Examples](references/examples.md)** - Complete Vue/NuxtJS mockup examples
- **[Deployment](references/deployment.md)** - Build and hosting guides for both frameworks
## Scripts
Helper scripts available in `scripts/` (Bash and PowerShell versions):
**create-component.sh / .ps1** - Generate components with TypeScript boilerplate
```bash
# Linux/macOS - Vue component
./scripts/create-component.sh ComponentName ui vue
# Linux/macOS - React component
./scripts/create-component.sh ComponentName ui react
# Windows - Vue component
.\scripts\create-component.ps1 -ComponentName ComponentName -Type ui -Framework vue
# Windows - React component
.\scripts\create-component.ps1 -ComponentName ComponentName -Type ui -Framework react
```
**build-deploy.sh / .ps1** - Build and prepare for deployment
```bash
# Linux/macOS
./scripts/build-deploy.sh
# Windows
.\scripts\build-deploy.ps1
```
**NuxtJS CLI commands:**
```bash
npx nuxi add component ComponentName # Add new component
npx nuxi add page pageName # Add new page
npx nuxi add layout layoutName # Add new layout
```
**Next.js CLI commands:**
```bash
# No built-in CLI for components, use scripts above
# Or manually create files in app/ or components/
```
## Troubleshooting
### NuxtJS (Vue)
**TailwindCSS v4 not working:**
- Restart dev server after nuxt.config.ts changes
- Verify `@import "tailwindcss";` in your CSS file
- Ensure `@tailwindcss/vite` plugin is in vite.plugins array
- Check CSS file is imported in nuxt.config.ts or app.vue
- Run `npx nuxi prepare` to regenerate types
**TypeScript errors:**
- Install Volar extension (not Vetur)
- Run `npx nuxi prepare` to generate types
- Restart TypeScript server in VS Code
**Auto-imports not working:**
```bash
rm -rf .nuxt
npx nuxi prepare
npm run dev
```
**HMR issues:**
```bash
rm -rf .nuxt node_modules/.cache
npm run dev
```
**Large bundle size:**
- Use lazy loading: `defineAsyncComponent(() => import('./Component.vue'))`
- Analyze with: `npx nuxi analyze`
### Next.js (React)
**TailwindCSS not working:**
- Check `tailwind.config.ts` has correct content paths
- Verify `@import "tailwindcss";` in app/globals.css
- Restart dev server after config changes
- Clear `.next` folder: `rm -rf .next && npm run dev`
**TypeScript errors:**
- Ensure tsconfig.json is properly configured
- Run `npm run build` to see full type checking
- Restart TypeScript server in VS Code
**Server vs Client Components:**
- Use `'use client'` directive at top of file for interactive components
- Server Components (default) cannot use hooks or event handlers
- Client Components can use useState, useEffect, onClick, etc.
**Build errors:**
```bash
rm -rf .next node_modules/.cache
npm install
npm run build
```
**Large bundle size:**
- Use dynamic imports: `const Component = dynamic(() => import('./Component'))`
- Analyze with: `npm run build` (shows bundle sizes)
## Best Practices
### Common (Both Frameworks)
1. **Component Design**: Small, single-purpose, reusable
2. **TypeScript**: Clear interfaces for props and component APIs
3. **TailwindCSS**: Prefer utilities over custom CSS
4. **Responsive**: Mobile-first approach
5. **Performance**: Use SSR/SSG when appropriate, lazy load large components
6. **Accessibility**: ARIA labels and keyboard navigation
7. **Code Organization**: Group related components, consistent naming
### NuxtJS (Vue) Specific
8. **Composables**: Extract shared logic (auto-imported)
9. **Auto-imports**: Leverage Nuxt's auto-import system for components and composables
10. **File-based Routing**: Use pages/ directory for automatic routing
11. **Layouts**: Create reusable layouts for consistent UI structure
12. **SEO**: Use `useHead()` and `useSeoMeta()` for meta tags
### Next.js (React) Specific
8. **Server Components**: Default to Server Components, use Client Components only when needed
9. **Data Fetching**: Use async Server Components for data fetching
10. **Metadata API**: Use `generateMetadata()` for dynamic SEO tags
11. **Image Optimization**: Use Next.js `` component for automatic optimization
12. **Route Handlers**: Use route.ts for API endpoints in app/api/