Build Your First Material App
This guide will walk you through building a simple Angular Material application from scratch. You’ll learn how to import components, use them in your templates, and apply Material Design principles.Make sure you’ve completed the Installation steps before starting this guide.
Step 1: Import Your First Component
Let’s start by adding a Material slide toggle to your application.Import the Module
In your component file, import
MatSlideToggleModule:app.component.ts
This example uses standalone components. If you’re using NgModules, add
MatSlideToggleModule to your module’s imports array instead.Run Your App
Start the development server:Open http://localhost:4200 in your browser. You should see a Material Design slide toggle!
Step 2: Build a Toolbar
Let’s create a Material toolbar for your application header.Step 3: Create a Card Layout
Let’s add some Material cards to display content.Step 4: Add a Form
Let’s create a simple form using Material form fields.Common Component Patterns
Using Forms
Using Forms
Material form fields work with both template-driven and reactive forms:All Material form components support Angular forms and validation.
Theming Components
Theming Components
Most components accept a
color attribute for theming:Accessibility
Accessibility
Material components are accessible by default. Always provide:
- Labels for form fields
aria-labelfor icon buttons- Proper heading hierarchy
- Keyboard navigation support
Component Variants
Component Variants
Many components have multiple variants:
Using Schematics
Angular Material includes schematics to generate pre-built components:Next Steps
Theming
Customize colors, typography, and density
Component API
Explore all available components
Accessibility
Learn about accessibility features
Schematics
Generate components with CLI
Additional Resources
Material Design Guidelines
Official Material Design specification
Angular Documentation
Learn more about Angular framework
Component Examples
Live examples and demos
GitHub Repository
Source code and issue tracker