Create Component Skill
Use this skill when the user asks to create a new UI component.
1. Standards & Stack
- •Framework: React 19 (Server Components by default, use
'use client'if interactivity is needed). - •Styling: Tailwind CSS v4 (Class-based).
- •Icons:
lucide-react(e.g.,import { User } from 'lucide-react'). - •Language: TypeScript (
.tsx).
2. Component Structure
File Location
- •Default:
apps/web/app/components/ - •Feature-specific:
apps/web/app/(routes)/[feature]/components/
Template
tsx
// If hooks (useState, useEffect) or event handlers are needed:
// 'use client';
import { clsx, type ClassValue } from 'clsx';
import { twMerge } from 'tailwind-merge';
import { IconName } from 'lucide-react'; // Example icon import
// Utility for cleaner execution (can be imported from @/lib/utils if available, else inline)
function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
interface ComponentNameProps {
className?: string;
variant?: 'primary' | 'secondary';
// Add other props here
}
export function ComponentName({
className,
variant = 'primary',
...props
}: ComponentNameProps) {
return (
<div
className={cn(
"flex items-center gap-2 p-4 rounded-xl transition-all",
variant === 'primary' ? "bg-blue-600 text-white" : "bg-gray-100 text-gray-900",
className
)}
{...props}
>
{/* Component Content */}
<span className="font-semibold">Component Content</span>
</div>
);
}
3. Checklist for Agent
- • Verify Path: Check if the file already exists to avoid accidental overwrites (unless requested).
- • Imports: Ensure
lucide-reacticons are imported correctly. - • Typing: Always define an interface for props.
- • Responsiveness: Use standard Tailwind breakpoints (
md:,lg:) if the component layout changes. - • Export: Use named exports (
export function).
4. Usage Example
User: "Crie um card de estatística simples."
Agent Action:
- •Create
apps/web/app/components/StatsCard.tsx. - •Implement using the template above.
- •Add proper props for
title,value,icon, andtrend.