--- name: svelte5-showcase-components description: | Provides Comprehensive guide to the Svelte 5 Showcase component library with 49 production-ready components organized into 7 categories. Use when you need to discover available components, understand component usage patterns, integrate components into new projects, or reference best practices for Svelte 5 development. Triggers on "what components are available", "how to use [component name]", "integrate showcase components", "copy component from showcase", "Svelte 5 component examples", or "showcase component library". Works with shadcn-svelte, Bits UI, TailwindCSS v4, sveltekit-superforms, and Svelte 5 runes. --- # Svelte 5 Showcase Components ## Quick Start The Svelte 5 Showcase is a production-ready component library with **49 components** organized into **7 categories**, built with Svelte 5 runes, TypeScript strict mode, and TailwindCSS v4. **Showcase Location:** `/Users/dawiddutoit/projects/play/svelte` **Component Categories:** 1. **Primitives** (24) - Core UI primitives (buttons, inputs, forms, dialogs) 2. **Navigation** (6) - Navigation patterns (tabs, breadcrumbs, pagination, menus) 3. **Data Display** (6) - Display components (tables, accordions, avatars, carousels) 4. **Overlays** (5) - Modal dialogs and overlays (popovers, sheets, drawers) 5. **Feedback** (2) - User feedback (progress bars, toast notifications) 6. **Layout** (2) - Layout primitives (aspect ratio, resizable panels) 7. **Custom** (4) - Brand-specific components (hero sections, service cards) **Quick Component Lookup:** ```bash # Browse all components at: /Users/dawiddutoit/projects/play/svelte/src/lib/components/ui/ # Example showcase pages: /Users/dawiddutoit/projects/play/svelte/src/routes/showcase/primitives/button/+page.svelte /Users/dawiddutoit/projects/play/svelte/src/routes/showcase/primitives/form/+page.svelte ``` --- ## Table of Contents 1. [When to Use This Skill](#1-when-to-use-this-skill) 2. [Component Inventory](#2-component-inventory) 3. [Quick Integration](#3-quick-integration) 4. [Common Usage Patterns](#4-common-usage-patterns) 5. [Form Handling](#5-form-handling) 6. [Supporting Files](#6-supporting-files) 7. [Expected Outcomes](#7-expected-outcomes) 8. [Requirements](#8-requirements) 9. [Red Flags to Avoid](#9-red-flags-to-avoid) --- ## When to Use This Skill ### Explicit Triggers Invoke this skill when the user explicitly asks for: - "What components are available in the showcase?" - "How do I use the [component name] component?" - "Show me examples of [component type]" - "How to integrate showcase components into my project?" - "Copy [component] from showcase to my project" - "What's the difference between Dialog and Drawer?" - "Showcase component documentation" ### Implicit Triggers Invoke when the user's task involves: - Building UI with Svelte 5 and needs component references - Looking for form validation examples with sveltekit-superforms - Needing accessible component patterns - Asking about Svelte 5 runes usage in components - Requesting Tailwind CSS component styling patterns - Exploring shadcn-svelte implementation examples ### Debugging Triggers Invoke when troubleshooting: - Import errors with showcase components - Svelte 5 runes syntax issues in components - Form validation not working with superforms - Tailwind classes not applying to components - TypeScript errors in component props - Component styling inconsistencies --- ## Component Inventory ### Complete Component List (49 Total) #### Primitives (24 components) **Form Controls:** - `Button` - Clickable button with variants (default, destructive, outline, ghost, link) - `Input` - Text input field with type variants - `Textarea` - Multi-line text input - `Checkbox` - Boolean checkbox with label - `Switch` - Toggle switch component - `Radio Group` - Radio button group - `Select` - Dropdown selection menu - `Slider` - Range slider input - `Label` - Accessible form label - `Input OTP` - One-time password input **Form Components:** - `Form Field` - Form field wrapper with context - `Form Label` - Accessible form label - `Form Description` - Helper text for fields - `Form Field Errors` - Validation error display - `Form Fieldset` - Group related fields - `Form Button` - Form submit button **Feedback & Display:** - `Alert` - Alert messages with variants - `Alert Dialog` - Modal confirmation dialog - `Badge` - Status badge with variants - `Card` - Container card with header/footer - `Dialog` - Modal dialog overlay - `Skeleton` - Loading skeleton placeholder - `Tooltip` - Hover tooltip - `Toggle` - Toggle button - `Toggle Group` - Toggle button group **Date Inputs:** - `Calendar` - Date picker calendar - `Range Calendar` - Date range picker #### Navigation (6 components) - `Breadcrumb` - Breadcrumb navigation trail - `Command` - Command palette / search - `Menubar` - Menu bar navigation - `Navigation Menu` - Dropdown navigation menu - `Pagination` - Page navigation - `Tabs` - Tabbed interface #### Data Display (6 components) - `Accordion` - Collapsible content sections - `Avatar` - User avatar with fallback - `Carousel` - Image/content carousel (Embla) - `Collapsible` - Single collapsible section - `Scroll Area` - Custom scrollbar area - `Table` - Data table with header/footer #### Overlays (5 components) - `Context Menu` - Right-click context menu - `Drawer` - Bottom drawer overlay (Vaul) - `Hover Card` - Hover card overlay - `Popover` - Popover overlay - `Sheet` - Side sheet overlay #### Feedback (2 components) - `Progress` - Progress bar indicator - `Sonner` - Toast notification system #### Layout (2 components) - `Aspect Ratio` - Aspect ratio container - `Resizable` - Resizable panel layout (Paneforge) #### Custom Components (4 components) - `Feature Card` - Branded feature card - `Hero Section` - Landing page hero - `Loading Spinner` - Custom loading animation - `Service Card` - Expandable service card with credentials **Location:** `/Users/dawiddutoit/projects/play/svelte/src/lib/components/ui/` --- ## Quick Integration ### Method 1: Using shadcn-svelte CLI (Recommended) ```bash # Install CLI and add components npx shadcn-svelte@latest add button npx shadcn-svelte@latest add card npx shadcn-svelte@latest add form ``` **What this does:** 1. Installs required dependencies 2. Copies component files to `src/lib/components/ui/` 3. Updates barrel exports in `index.ts` ### Method 2: Manual Copy from Showcase **Step 1: Copy component directory** ```bash # Copy button component cp -r /Users/dawiddutoit/projects/play/svelte/src/lib/components/ui/button \ ./src/lib/components/ui/ # Copy multiple components cp -r /Users/dawiddutoit/projects/play/svelte/src/lib/components/ui/{button,card,input} \ ./src/lib/components/ui/ ``` **Step 2: Update barrel exports** ```typescript // src/lib/components/index.ts export { Button, buttonVariants } from './ui/button'; export { Card, CardHeader, CardTitle, CardContent, CardFooter } from './ui/card'; export { Input } from './ui/input'; ``` **Step 3: Install dependencies** ```bash npm install bits-ui clsx tailwind-merge tailwind-variants lucide-svelte ``` **Step 4: Copy utilities** ```typescript // src/lib/utils.ts import { clsx, type ClassValue } from 'clsx'; import { twMerge } from 'tailwind-merge'; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } export type WithElementRef = T & { ref?: U | null }; ``` ### Method 3: Read from Showcase ```svelte ``` **View showcase examples:** ``` /Users/dawiddutoit/projects/play/svelte/src/routes/showcase/primitives/[component]/+page.svelte ``` --- ## Common Usage Patterns ### Svelte 5 Runes (Required Syntax) All components use Svelte 5 runes: ```svelte ``` ### Props Pattern ```svelte ``` ### Bindable Props ```svelte onChange?.(value)} /> ``` ### Component Composition ```svelte Card Title

Card content goes here

``` ### Tailwind Class Merging ```svelte
Content
``` ### Icon Integration ```svelte ``` --- ## Form Handling ### Complete Form Integration **1. Create Zod Schema:** ```typescript // schema.ts import { z } from 'zod'; export const contactSchema = z.object({ name: z.string().min(2, 'Name must be at least 2 characters'), email: z.string().email('Invalid email address'), message: z.string().min(10, 'Message must be at least 10 characters'), newsletter: z.boolean().default(false) }); export type ContactForm = z.infer; ``` **2. Server-Side Validation:** ```typescript // +page.server.ts import type { PageServerLoad, Actions } from './$types'; import { superValidate } from 'sveltekit-superforms'; import { zod } from 'sveltekit-superforms/adapters'; import { contactSchema } from './schema'; import { fail } from '@sveltejs/kit'; export const load: PageServerLoad = async () => { const form = await superValidate(zod(contactSchema)); return { form }; }; export const actions: Actions = { default: async ({ request }) => { const form = await superValidate(request, zod(contactSchema)); if (!form.valid) { return fail(400, { form }); } // Process form data console.log('Form submitted:', form.data); return { form }; } }; ``` **3. Client-Side Component:** ```svelte
{#snippet children({ value })} Full Name {/snippet} {#snippet children({ value })} Email We'll never share your email {/snippet} {#snippet children({ value })} Message