Create a new UX pattern example with all required files (index.ts, GoodExample.tsx, BadExample.tsx, README.md). Use when adding a new good/bad UX comparison or pattern to the project.
This skill helps you scaffold a complete UX pattern example following project conventions.
Each example requires 4 files in src/examples/{example-id}/:
src/examples/{example-id}/
āāā index.ts # Metadata and exports
āāā GoodExample.tsx # Correct implementation
āāā BadExample.tsx # Implementation to avoid
āāā README.md # Pattern documentation
Use kebab-case for the folder name: src/examples/my-new-pattern/
import { GoodExample } from "./GoodExample";
import { BadExample } from "./BadExample";
import content from "./README.md?raw";
export { content };
export const meta = {
id: "my-new-pattern", // Must match folder name
title: "Pattern Title",
description: "Brief description of the pattern",
category: "Forms", // One of: Forms, Navigation, Feedback, Accessibility, Performance, Modals, Input
tags: ["tag1", "tag2"],
createdAt: "YYYY-MM-DD", // Today's date in ISO format
aiSummary: "Concise, actionable summary for AI assistants. Focus on WHEN to apply and HOW. Example: 'When building X, do Y. Don't do Z.'",
};
export const BadExamples = [
{ component: BadExample, label: "Without pattern" },
];
export const GoodExamples = [
{ component: GoodExample, label: "With pattern" },
];
import { useState } from "react";
import { Button } from "@/components/ui/button";
// Import other UI components as needed from @/components/ui/
export function GoodExample() {
// Implementation showing the CORRECT pattern
return (
<div>
{/* Good UX implementation */}
</div>
);
}
import { useState } from "react";
import { Button } from "@/components/ui/button";
export function BadExample() {
// Implementation showing the pattern to AVOID
return (
<div>
{/* Bad UX implementation */}
</div>
);
}
# Pattern Title
## Description
Clear explanation of the UX pattern.
## Why it matters
- **Benefit 1**: Explanation
- **Benefit 2**: Explanation
- **Benefit 3**: Explanation
## When to apply
- Use case 1
- Use case 2
## When not to apply
- Exception 1
- Exception 2
Add import and include in examples array:
import * as myNewPattern from "./my-new-pattern";
export const examples = [
// ... existing examples
myNewPattern,
];
Existing categories:
Forms - Form inputs, validation, submissionNavigation - Navigation patterns, scroll behaviorFeedback - User feedback, notifications, loading statesAccessibility - A11y patterns, focus managementPerformance - Perceived performance, loading optimizationModals - Modal dialogs, overlays, popupsYou can create new categories if the pattern doesn't fit existing ones.
Existing components in @/components/ui/:
button - Button componentinput - Input fieldlabel - Form labeldialog - Modal dialog (Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogTrigger)You can create new UI components in src/components/ui/ if needed (following shadcn/ui patterns).
dark: variants