Frontend Components

Create and maintain React TSX components with CVA variants and cn() utility.

1|Updated Dec 4, 2024
One-click install
npx skills add https://github.com/imkdw/imkdw-dev --skill frontend-components-imkdw
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Frontend Components
Source: https://github.com/imkdw/imkdw-dev/tree/main/.claude/skills/frontend-components
Command: npx skills add https://github.com/imkdw/imkdw-dev --skill frontend-components-imkdw

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Inconsistent component design and architecture lead to duplicated effort, maintenance headaches, and a fragmented user experience. This Skill establishes clear, scalable patterns for building React components within a Next.js App Router environment.

Core Features & Use Cases

  • Design System Integration: Build components using class-variance-authority (CVA) for robust variant management and cn() for efficient class merging, ensuring design consistency.
  • Server/Client Component Strategy: Effectively differentiate and implement Next.js Server and Client Components, optimizing performance and leveraging React's latest features.
  • Modular Structure: Organize primitives and complex components into a logical directory structure, promoting maximum reusability and maintainability.
  • Use Case: When creating a new ArticleCard component, ensure it composes existing primitives like Card and Badge, uses CVA for styling variants, and is correctly implemented as a Server or Client Component based on its interactivity needs.

Quick Start

Help me create a new Alert component that supports success, warning, and error variants using class-variance-authority and cn() for styling, and define its TypeScript props interface.

Frequently Asked Questions about Frontend Components

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure React components in a Next.js design system?

Structure React components by organizing primitives and complex components under packages/ui, using functional component definitions with TypeScript Props interfaces, and composing primitives into complex components like ArticleCard. This approach ensures consistency and reusability across your Next.js App Router application.

What's the best way to manage component variants in React with TypeScript?

Use class-variance-authority (CVA) to define robust styling variants for your React components, then merge classes with the cn() utility. This pattern eliminates duplicated styling logic and ensures type-safe variant management across your design system.

When should I use Server Components vs Client Components in Next.js?

Server Components are the default in Next.js 19 App Router; use them for components that don't require interactivity. Add the 'use client' directive only to components needing client-side features like state or event handlers, optimizing performance while leveraging React's latest capabilities.

Can I reuse components across multiple Next.js applications?

Yes. Centralize reusable components in packages/ui and import them as @imkdw-dev/ui across apps/blog and other applications. This shared design system reduces duplication and maintains UI consistency enterprise-wide.

How do I define component props with TypeScript in a design system?

Create Props interfaces for each component, naming them [ComponentName]Props, and extend them with CVA variant types. Export these interfaces so consumers can type-check their component usage, catching prop errors at build time rather than runtime.

What are the limitations of class-variance-authority for styling variants?

CVA excels at CSS class variant management but requires your styling to live in CSS files or Tailwind classes. If your design system uses runtime CSS-in-JS, you'll need to adapt the pattern or combine CVA with your CSS-in-JS library for full consistency.