# Fakemui Migration Guide Guide for migrating from custom CSS, Tailwind, or other UI libraries to Fakemui. ## Why Migrate to Fakemui? | Benefit | Impact | |---------|--------| | **Consistency** | Unified Material Design 3 across all projects | | **Development Speed** | Pre-built components reduce custom CSS by ~90% | | **Accessibility** | WCAG AA+ compliance built-in | | **Type Safety** | Full TypeScript support for all components | | **Maintainability** | Shared component library across team | | **Performance** | Optimized rendering and bundle size | | **Theming** | 9 built-in themes + custom theme support | ## Migration Strategies ### Strategy 1: Incremental Component Replacement (Recommended) Replace components one by one while keeping existing code working: **Step 1: Add Fakemui to your project** ```bash # Already available in MetaBuilder monorepo import { Button, Card } from '@/fakemui' ``` **Step 2: Replace one component at a time** Before (Custom CSS): ```tsx import './styles.css' export function MyComponent() { return (

Title

) } /* styles.css */ .card { border: 1px solid #ddd; border-radius: 8px; padding: 16px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); } .card-title { font-size: 20px; font-weight: 600; margin: 0 0 12px 0; } .btn { padding: 8px 16px; border-radius: 4px; cursor: pointer; } .btn-primary { background-color: #1976d2; color: white; } ``` After (Fakemui): ```tsx import { Card, Typography, Button } from '@/fakemui' export function MyComponent() { return ( Title ) } ``` **Benefits**: - No breaking changes - Can test each replacement - Gradual team adoption - Rollback if needed ### Strategy 2: Page-by-Page Replacement Rewrite entire pages to use Fakemui: **Step 1: Pick a new page or low-traffic page** ```tsx // pages/settings.tsx - Less critical, good for testing ``` **Step 2: Rewrite using Fakemui** ```tsx import { Box, TextField, Button, Card, Stack, Typography } from '@/fakemui' export function SettingsPage() { return ( Settings ) } ``` **Step 3: Move to production, gather feedback** **Step 4: Migrate next page** **Benefits**: - Clear scope boundaries - Easy to compare before/after - Easier testing and review ### Strategy 3: New Features Only Use Fakemui exclusively for new features: ```tsx // Old code with custom CSS (leave as-is)
...
// New features use Fakemui import { Dialog, Button } from '@/fakemui' export function NewFeatureDialog() { return New feature content } ``` **Benefits**: - Zero risk to existing code - Natural migration over time - Team learns Fakemui gradually ## Common Migration Patterns ### Pattern 1: Layout (Flexbox/Grid) **Before (Tailwind)**: ```tsx
Half width
Half width
``` **After (Fakemui)**: ```tsx import { Box, Grid, Stack } from '@/fakemui' Half width Half width ``` **Key mappings**: | Tailwind | Fakemui | |----------|---------| | `flex` | `` or `sx={{ display: 'flex' }}` | | `flex-col` | `` | | `gap-4` | `spacing={2}` (8px units) | | `p-6` | `sx={{ p: 3 }}` (16px units) | | `grid grid-cols-2` | `` | | `max-w-2xl` | `sx={{ maxWidth: 600 }}` | | `mx-auto` | `sx={{ mx: 'auto' }}` | ### Pattern 2: Buttons **Before (Custom CSS)**: ```tsx /* CSS */ .btn { padding: 8px 16px; border: none; border-radius: 4px; cursor: pointer; font-weight: 500; } .btn-primary { background-color: #1976d2; color: white; } .btn-lg { padding: 12px 32px; font-size: 16px; } ``` **After (Fakemui)**: ```tsx import { Button } from '@/fakemui' ``` **Button variant mapping**: | Custom | Fakemui | |--------|---------| | Primary button | ` /* CSS */ .form-group { margin-bottom: 16px; } .form-label { display: block; font-weight: 500; margin-bottom: 4px; } .form-input { width: 100%; padding: 8px 12px; border: 1px solid #ccc; border-radius: 4px; } .form-error { color: #d32f2f; font-size: 12px; } ``` **After (Fakemui)**: ```tsx import { TextField, Button, Box } from '@/fakemui' import { useState } from 'react' export function MyForm() { const [errors, setErrors] = useState({}) const handleSubmit = async (e) => { e.preventDefault() // Validation logic } return ( ) } ``` **Form component mapping**: | Custom | Fakemui | |--------|---------| | Text input | `` | | Select dropdown | `