This document outlines the migration from legacy Angular Material to Material 3 (MDC-based components) for the ngx-form-lib project.
- Before:
deeppurple-amber.css(legacy theme) - After:
indigo-pink.css(Material 3 theme) - Files Updated:
angular.json(both build and test configurations)
Added support for Material 3 button variants in button-attribute.model.ts:
// New Material 3 variants
MatFilledButton = 'mat-fill',
MatOutlinedButton = 'mat-outline',
MatTextButton = 'mat-text',
MatElevatedButton = 'mat-elevated',
MatTonalButton = 'mat-tonal',- Updated
button.component.htmlto support new Material 3 button classes - Maintained backward compatibility with legacy button variants
- Added proper Material 3 styling
Enhanced button.component.scss with Material 3 design principles:
- Rounded corners (20px border-radius)
- Material 3 typography (font-weight: 500)
- No text transform (removed uppercase)
- Smooth transitions
- Material 3 color variables
Updated styles.scss with Material 3 form field improvements:
- Larger border radius (8px) for form fields
- Material 3 typography for error messages
- Enhanced focus states
- Material 3 color variables
Enhanced form.component.scss:
- Larger border radius (12px) for form containers
- Material 3 elevation (box-shadow)
- Improved visual hierarchy
- Input: Enhanced with Material 3 styling
- Textarea: Enhanced with Material 3 styling
- Dropdown: Enhanced with Material 3 styling
- Checkbox: Rounded corners (4px border-radius)
- Radio: Circular radio buttons
- Button: Multiple Material 3 variants
Updated form.mock.ts:
- Changed button attribute from
'mat-flat-button'to'mat-fill' - Changed form appearance from
'outline'to'fill'
- Form containers: 12px border-radius
- Form fields: 8px border-radius
- Buttons: 20px border-radius
- Checkboxes: 4px border-radius
- Font weight: 500 for buttons
- No text transform (removed uppercase)
- Consistent font sizes
- Material 3 box-shadow for form containers
- Proper elevation for elevated buttons
- Using Material 3 CSS custom properties
- Consistent color theming
- Proper contrast ratios
- Smooth 0.2s ease-in-out transitions
- Consistent animation timing
The migration maintains full backward compatibility:
- Legacy button variants still work
- Existing form configurations continue to function
- No breaking changes to the API
- Modern Design: Updated to latest Material Design guidelines
- Better Accessibility: Improved focus states and contrast
- Consistent Theming: Better integration with Material 3 themes
- Performance: MDC-based components are more performant
- Future-Proof: Ready for future Material Design updates
// Filled button (primary action)
new Button({
attribute: 'mat-fill',
field: new Field<string>({...})
})
// Outlined button (secondary action)
new Button({
attribute: 'mat-outline',
field: new Field<string>({...})
})
// Text button (tertiary action)
new Button({
attribute: 'mat-text',
field: new Field<string>({...})
})
// Elevated button (with shadow)
new Button({
attribute: 'mat-elevated',
field: new Field<string>({...})
})
// Tonal button (subtle emphasis)
new Button({
attribute: 'mat-tonal',
field: new Field<string>({...})
})new ParentConfig({
appearance: "fill", // Material 3 filled appearance
color: "primary",
});To test the Material 3 migration:
- Build the project:
npm run build - Serve the application:
npm start - Verify visual changes: Check form appearance and button variants
- Test functionality: Ensure all form interactions work correctly
- Dark Theme Support: Add Material 3 dark theme
- Custom Theming: Implement custom Material 3 theme
- Animation Enhancements: Add Material 3 motion
- Accessibility: Further improve accessibility features
- The bundle size increased slightly due to Material 3 enhancements
- All existing functionality remains intact
- The migration is non-breaking for existing implementations
- Material 3 provides better performance and accessibility