# Fakemui Theming Guide Complete guide to theming in Fakemui, including built-in themes, customization, and dynamic theme switching. ## Overview Fakemui's theming system is based on Material Design 3, providing a comprehensive design token system for consistent, accessible, and customizable user interfaces. **Key features**: - 9 built-in themes - Custom theme creation - Dynamic theme switching - Material Design 3 compliance - Accessibility standards (WCAG AA+) ## Built-in Themes ### Available Themes | Theme | Description | Use Case | |-------|-------------|----------| | **default** | Primary blue (Material Design 3 default) | General applications | | **light** | Light mode optimization | Daytime/bright environments | | **dark** | Dark mode optimization | Nighttime/reduced eye strain | | **ocean** | Ocean blue with teal accents | Calm, professional applications | | **forest** | Green with natural tones | Environmental/wellness apps | | **sunset** | Warm orange/red tones | Creative/vibrant applications | | **lavender** | Purple with soft tones | Design-focused applications | | **midnight** | Deep blue with dark background | Night mode preference | | **rose** | Pink/rose tones | Fashion/lifestyle applications | ### Theme Structure Each theme defines: ```typescript interface Theme { palette: { // Primary colors primary: { main, light, dark, contrastText } secondary: { main, light, dark, contrastText } error: { main, light, dark, contrastText } warning: { main, light, dark, contrastText } info: { main, light, dark, contrastText } success: { main, light, dark, contrastText } // Neutral colors background: { default, paper } text: { primary, secondary, disabled, hint } divider: color action: { active, hover, selected, disabled } // Elevation colors (5 levels) surface1, surface2, surface3, surface4, surface5 } typography: { fontFamily: string fontSize: number fontWeightLight: number fontWeightRegular: number fontWeightMedium: number fontWeightBold: number // Typography variants h1, h2, h3, h4, h5, h6: TypographyOptions body1, body2: TypographyOptions button, caption: TypographyOptions } spacing: (multiplier: number) => number shape: { borderRadius: number } shadows: string[] transitions: { duration: { shortest, shorter, standard, complex } easing: { easeInOut, easeOut, easeIn, linear } } } ``` ## Using Built-in Themes ### Basic Theme Setup ```typescript import { ThemeProvider } from '@/fakemui/theming' import App from './App' export function Root() { return ( ) } ``` ### Reading Current Theme ```typescript import { useTheme } from '@/fakemui/theming' export function ComponentWithTheme() { const { theme, palette } = useTheme() return ( Current theme: {theme} ) } ``` ### Accessing Theme in sx Prop ```typescript import { Box, Button } from '@/fakemui' export function StyledComponent() { return ( Content with theme ) } ``` ## Creating Custom Themes ### Option 1: Extend Existing Theme ```typescript import { createTheme } from '@/fakemui/theming' const customTheme = createTheme({ palette: { primary: { main: '#6366f1', // Indigo light: '#818cf8', dark: '#4f46e5', contrastText: '#ffffff' }, secondary: { main: '#ec4899', // Pink light: '#f472b6', dark: '#db2777', contrastText: '#ffffff' } }, typography: { fontFamily: "'Inter', sans-serif", fontSize: 14 } }) // Use custom theme ``` ### Option 2: Full Theme Customization ```typescript import { createTheme } from '@/fakemui/theming' const brandTheme = createTheme({ palette: { primary: { main: '#2563eb', // Brand blue light: '#3b82f6', dark: '#1d4ed8', contrastText: '#ffffff' }, secondary: { main: '#7c3aed', // Brand purple light: '#a78bfa', dark: '#6d28d9', contrastText: '#ffffff' }, success: { main: '#10b981', light: '#34d399', dark: '#059669', contrastText: '#ffffff' }, warning: { main: '#f59e0b', light: '#fbbf24', dark: '#d97706', contrastText: '#ffffff' }, error: { main: '#ef4444', light: '#f87171', dark: '#dc2626', contrastText: '#ffffff' }, background: { default: '#ffffff', paper: '#f9fafb' }, text: { primary: 'rgba(0, 0, 0, 0.87)', secondary: 'rgba(0, 0, 0, 0.60)', disabled: 'rgba(0, 0, 0, 0.38)', hint: 'rgba(0, 0, 0, 0.38)' }, divider: 'rgba(0, 0, 0, 0.12)', action: { active: 'rgba(0, 0, 0, 0.54)', hover: 'rgba(0, 0, 0, 0.04)', selected: 'rgba(0, 0, 0, 0.08)', disabled: 'rgba(0, 0, 0, 0.26)' } }, typography: { fontFamily: "'Roboto', sans-serif", fontSize: 14, fontWeightLight: 300, fontWeightRegular: 400, fontWeightMedium: 500, fontWeightBold: 700, h1: { fontSize: '6rem', fontWeight: 300, lineHeight: 1.167, letterSpacing: '-0.015625em' }, h2: { fontSize: '3.75rem', fontWeight: 300, lineHeight: 1.2, letterSpacing: 0 }, h3: { fontSize: '3rem', fontWeight: 400, lineHeight: 1.167, letterSpacing: '0.0125em' }, h4: { fontSize: '2.125rem', fontWeight: 500, lineHeight: 1.235, letterSpacing: 0 }, h5: { fontSize: '1.5rem', fontWeight: 500, lineHeight: 1.334, letterSpacing: 0 }, h6: { fontSize: '1.25rem', fontWeight: 500, lineHeight: 1.6, letterSpacing: '0.0125em' }, body1: { fontSize: '1rem', fontWeight: 400, lineHeight: 1.5, letterSpacing: '0.03125em' }, body2: { fontSize: '0.875rem', fontWeight: 400, lineHeight: 1.43, letterSpacing: '0.0178571429em' }, button: { fontSize: '0.875rem', fontWeight: 500, lineHeight: 1.75, letterSpacing: '0.0892857143em', textTransform: 'uppercase' }, caption: { fontSize: '0.75rem', fontWeight: 500, lineHeight: 1.67, letterSpacing: '0.0333333333em' } }, shape: { borderRadius: 4 }, shadows: [ 'none', '0px 2px 1px -1px rgba(0,0,0,0.2)', '0px 3px 1px -2px rgba(0,0,0,0.2)', '0px 3px 3px -2px rgba(0,0,0,0.2)', '0px 2px 4px -1px rgba(0,0,0,0.2)', '0px 3px 5px -1px rgba(0,0,0,0.2)' ], transitions: { duration: { shortest: 150, shorter: 200, standard: 300, complex: 375 }, easing: { easeInOut: 'cubic-bezier(0.4, 0, 0.2, 1)', easeOut: 'cubic-bezier(0.0, 0, 0.2, 1)', easeIn: 'cubic-bezier(0.4, 0, 1, 1)', linear: 'linear' } } }) ``` ## Dynamic Theme Switching ### Basic Theme Switcher ```typescript import { Box, Button, Stack } from '@/fakemui' import { useTheme } from '@/fakemui/theming' export function ThemeSwitcher() { const { theme, setTheme } = useTheme() const themes = ['default', 'dark', 'ocean', 'forest', 'sunset'] return (

Current theme: {theme}

{themes.map((t) => ( ))}
) } ``` ### Theme Switcher in AppBar ```typescript import { AppBar, Toolbar, Box, Select } from '@/fakemui' import { useTheme } from '@/fakemui/theming' export function Header() { const { theme, setTheme } = useTheme() return ( MyApp