Theme Customization
Material UI uses a powerful theming system powered bycreateTheme to customize the look and feel of your application.
Creating a Theme
ThecreateTheme function generates a theme object that defines your design system.
Theme Structure
A complete theme object includes:- palette - Color palette configuration
- typography - Typography system settings
- spacing - Spacing scale (default: 8px)
- breakpoints - Responsive breakpoint values
- shape - Border radius configuration
- shadows - Elevation shadow definitions
- transitions - Animation duration and easing
- zIndex - Z-index layering system
- components - Component-specific overrides
API Signature
Parameters
options (ThemeOptions): Takes an incomplete theme object and adds the missing parts. …args (object[]): Deep merge additional arguments with the theme. Returns: A complete, ready-to-use theme object.Merging Themes
You can pass multiple theme objects to merge them:Accessing Theme in Components
Use theuseTheme hook to access theme values:
Theme with Custom Properties
Extend the theme with custom properties:Spacing Helper
The theme provides aspacing function for consistent spacing:
Custom Spacing
Override the default spacing:TypeScript
To add custom properties with TypeScript, use module augmentation:Source Reference
The createTheme implementation can be found at:packages/mui-material/src/styles/createTheme.ts:61packages/mui-material/src/styles/createThemeNoVars.js:74