# UI Components A comprehensive design system of reusable UI components for the KLZ Cables Next.js application. Built with TypeScript, Tailwind CSS, and accessibility best practices. ## Overview This component library provides building blocks for creating consistent, responsive, and accessible user interfaces. All components are fully typed with TypeScript and follow modern web standards. ## Components ### 1. Button Component A versatile button component with multiple variants, sizes, and states. **Features:** - Multiple variants: `primary`, `secondary`, `outline`, `ghost` - Three sizes: `sm`, `md`, `lg` - Icon support with left/right positioning - Loading state with spinner - Full width option - Proper accessibility attributes **Usage:** ```tsx import { Button } from '@/components/ui'; // Basic usage // With icon // Loading state // Disabled // Full width ``` ### 2. Card Component Flexible container component with optional header, body, footer, and image sections. **Features:** - Three variants: `elevated`, `flat`, `bordered` - Optional padding: `none`, `sm`, `md`, `lg`, `xl` - Hover effects - Image support (top or background) - Composable sub-components **Usage:** ```tsx import { Card, CardHeader, CardBody, CardFooter, CardImage } from '@/components/ui'; // Basic card

Card content goes here

// Card with image
// Hoverable card {/* content */} ``` ### 3. Container Component Responsive wrapper for centering content with configurable max-width and padding. **Features:** - Max-width options: `xs` to `6xl`, `full` - Padding options: `none`, `sm`, `md`, `lg`, `xl`, `2xl` - Centering option - Fluid mode (full width) **Usage:** ```tsx import { Container } from '@/components/ui'; // Standard container // Medium container // Fluid (full width) // Without centering ``` ### 4. Grid Component Responsive grid system with configurable columns and gaps. **Features:** - 1-12 column system - Responsive breakpoints: `colsSm`, `colsMd`, `colsLg`, `colsXl` - Gap spacing: `none`, `xs`, `sm`, `md`, `lg`, `xl`, `2xl` - Grid item span control - Alignment options **Usage:** ```tsx import { Grid, GridItem } from '@/components/ui'; // Basic grid
Item 1
Item 2
Item 3
// Responsive grid {/* items */} // Grid with spans Spans 2 columns 1 column // Grid with alignment {/* items */} ``` ### 5. Badge Component Small status or label component with multiple variants. **Features:** - Color variants: `primary`, `secondary`, `success`, `warning`, `error`, `info`, `neutral` - Sizes: `sm`, `md`, `lg` - Icon support with positioning - Rounded or squared - Badge group for multiple badges **Usage:** ```tsx import { Badge, BadgeGroup } from '@/components/ui'; // Basic badge Active // With icon }>Featured // Different sizes Small Medium Large // Badge group React TypeScript Tailwind // Rounded Rounded ``` ### 6. Loading Component Loading indicators including spinners, buttons, and skeletons. **Features:** - Spinner sizes: `sm`, `md`, `lg`, `xl` - Spinner variants: `primary`, `secondary`, `neutral`, `contrast` - Optional text - Overlay mode with fullscreen option - Loading button - Skeleton loaders **Usage:** ```tsx import { Loading, LoadingButton, LoadingSkeleton } from '@/components/ui'; // Basic spinner // With text // Overlay (blocks UI) // Fullscreen overlay // Loading button // Skeleton loaders ``` ## TypeScript Support All components are fully typed with TypeScript. Props are exported for external use: ```tsx import type { ButtonProps, CardProps, ContainerProps, GridProps, BadgeProps, LoadingProps } from '@/components/ui'; ``` ## Accessibility All components include proper accessibility attributes: - ARIA labels where needed - Keyboard navigation support - Focus management - Screen reader friendly - Color contrast compliance ## Responsive Design Components are built with mobile-first responsive design: - Tailwind responsive prefixes (`sm:`, `md:`, `lg:`, `xl:`) - Flexible layouts - Touch-friendly sizes - Adaptive spacing ## Customization All components support the `className` prop for custom styling: ```tsx ``` ## Best Practices 1. **Always use the index export:** ```tsx import { Button, Card } from '@/components/ui'; ``` 2. **Type your props:** ```tsx interface MyComponentProps { title: string; variant?: ButtonVariant; } ``` 3. **Use semantic HTML:** - Buttons for actions - Links for navigation - Proper heading hierarchy 4. **Test with keyboard:** - Tab through all interactive elements - Enter/Space activates buttons - Escape closes modals 5. **Test with screen readers:** - Use VoiceOver (macOS) or NVDA (Windows) - Verify ARIA labels are descriptive ## Performance Tips 1. **Lazy load heavy components:** ```tsx const HeavyComponent = dynamic(() => import('@/components/Heavy'), { loading: () => }); ``` 2. **Memoize expensive computations:** ```tsx const memoizedValue = useMemo(() => computeExpensiveValue(), [deps]); ``` 3. **Use proper image optimization:** ```tsx ``` ## Browser Support - Chrome/Edge: Latest 2 versions - Firefox: Latest 2 versions - Safari: Latest 2 versions - Mobile browsers: iOS Safari, Chrome Mobile ## Future Enhancements - [ ] Modal component - [ ] Dropdown component - [ ] Tabs component - [ ] Accordion component - [ ] Tooltip component - [ ] Toast/Notification component - [ ] Form input components - [ ] Table component ## Contributing When adding new components: 1. Follow the existing component structure 2. Use TypeScript interfaces 3. Include proper accessibility attributes 4. Add to the index export 5. Update this documentation 6. Test across browsers and devices ## License Internal use only - KLZ Cables