# React Component Scaffold Example Complete example of scaffolding a reusable React component with TypeScript, tests, Storybook stories, and CSS modules. **Duration**: 5 minutes | **Files**: 6 | **LOC**: ~120 | **Stack**: React + TypeScript + Vitest + Storybook --- ## File Tree ``` src/components/Button/ ├── Button.tsx # Component implementation ├── Button.test.tsx # Vitest + Testing Library tests ├── Button.stories.tsx # Storybook stories ├── Button.module.css # CSS modules styling ├── index.ts # Re-exports └── README.md # Component documentation ``` --- ## Generated Files ### 1. Button.tsx (Implementation) ```typescript import React from 'react'; import styles from './Button.module.css'; export interface ButtonProps { /** Button label */ label: string; /** Button variant */ variant?: 'primary' | 'secondary' | 'danger'; /** Button size */ size?: 'small' | 'medium' | 'large'; /** Disabled state */ disabled?: boolean; /** Click handler */ onClick?: () => void; } export const Button: React.FC = ({ label, variant = 'primary', size = 'medium', disabled = false, onClick, }) => { const className = [ styles.button, styles[variant], styles[size], disabled && styles.disabled, ].filter(Boolean).join(' '); return ( ); }; ``` ### 2. Button.test.tsx (Tests) ```typescript import { describe, it, expect, vi } from 'vitest'; import { render, screen, fireEvent } from '@testing-library/react'; import { Button } from './Button'; describe('Button', () => { it('renders with label', () => { render(