Overview
Angular Material comes with built-in schematics that help you quickly generate pre-configured components using the Angular CLI. These schematics create production-ready components with Material Design best practices already implemented.Schematics are included with both
@angular/material and @angular/cdk. Once installed, they’re available through the Angular CLI.Installation Schematic
The easiest way to add Angular Material to your project is using theng add schematic:
Install Dependencies
Adds
@angular/material, @angular/cdk, and @angular/animations to your package.jsonComponent Schematics
Angular Material provides several component schematics to quickly generate common UI patterns:Navigation Schematic
Generates a component with a responsive Material sidenav and toolbar:- Responsive side navigation using
<mat-sidenav> - App toolbar with menu button using
<mat-toolbar> - Breakpoint detection for mobile/desktop layouts
- Navigation links in the sidenav
Table Schematic
Generates a component with a Material data table configured for sorting and pagination:<mat-table>with column definitionsMatTableDataSourcefor data managementmat-sortfor sortable columnsmat-paginatorfor pagination- Sample data structure
Dashboard Schematic
Generates a component with a responsive grid dashboard layout:- Responsive grid layout using CSS Grid
- Multiple
<mat-card>components - Card headers and content areas
- Responsive breakpoint handling
Address Form Schematic
Generates a component with a form using Material form controls:- Reactive form with form validation
- Material form fields (
<mat-form-field>) - Material input controls
- Material radio buttons
- Material select dropdowns
- Submit button with Material styling
Tree Schematic
Generates a component that visualizes nested data using<mat-tree>:
<mat-tree>component with nested nodes- Expandable/collapsible tree structure
- Material icons for expand/collapse
- Sample hierarchical data structure
CDK Schematics
The Angular CDK also provides schematics:Drag and Drop Schematic
Generates a component using CDK drag-drop directives:- Interactive drag-and-drop list
cdkDropListandcdkDragdirectives- Drop event handling
- Sample to-do list structure
Theme Color Schematic
Generates Material 3 color palettes from custom colors:Learn more in the theme-color schematic documentation.
Using Generated Components
After generating a component, you can use it in your application:Import the Component
Import the generated component in your routes or parent component:
app.routes.ts
Customize the Component
Modify the generated code to fit your needs:
- Update data sources
- Add your business logic
- Adjust styling
- Modify templates
Schematic Options
Many schematics accept additional options:The project to generate the component in (for multi-project workspaces)
The path to create the component in
The module to import the component into (for NgModule-based apps)
Whether to export the component from the module
Whether to skip importing the component into a module
Example with Options
Best Practices
Start with Schematics
Start with Schematics
Use schematics as a starting point, then customize:
- Schematics provide best-practice patterns
- They include proper imports and setup
- Modify generated code to match your needs
- Learn Material patterns from the generated code
Organize Generated Components
Organize Generated Components
Keep your project organized:
Review Generated Code
Review Generated Code
Always review and understand the generated code:
- Check imports and dependencies
- Understand the data flow
- Review accessibility features
- Customize for your use case
Combine Schematics
Combine Schematics
Use multiple schematics together:
Example: Building a Complete Feature
Here’s how to use schematics to build a complete user management feature:Resources
Angular Schematics
Learn about Angular schematics
Theme Color Schematic
Custom palette generation guide
Component Examples
See live examples of components
Quick Start
Build your first Material app
Next Steps
Theming
Customize your generated components
Components
Explore all Material components
Accessibility
Ensure your components are accessible