Skip to content
  • iImagine
  • Register
  • Log In

Web Development School

Learning made easy.

  • Books
    • Beginning Web Development with ASP.Net Core & Client-Side Technologies
      • TOC
      • Part 1
        • Chapter 1: Static HTML – Designing the landing page
      • Part 2
        • Chapter 2: ASP.Net Core – Let’s talk Dynamic
        • Chapter 3: Introduction to ASP.Net Core MVC
          [ASP.Net Core v9]
      • Part 4
        • Chapter 7: Using Server Side & Client Side technologies together
          [ASP.Net Core v7 & Angular 15]
  • Environment Setup
    • Installing Angular
    • Installing Visual Studio 2022
    • Installing SQL Server 2022 Express
    • Installing Postman
    • Installing Git for Windows
  • Blog
  • iImagine WebSolutions
  • Events
  • Learning Videos
  • Toggle search form

Using a Component Library: Angular Material

Up until now we have been using custom CSS and Bootstrap, a CSS library to style our web applications. In this chapter we are going to take a look at using Angular Material to add style and dress up the FredsCars website.

Note: At this point I am copying the project from the Module11 folder to a Module12 folder. The pathway I am using for development here is:
C:\Development\FredsCars\FullStack\Module12.
Table Of Contents
  1. What is Angular Material
  2. Installing Angular Material
  3. View Angular Material Typography Styles
  4. Give me some space!
  5. What's Next

What is Angular Material

It’s hard to find a great definition of what exactly Angular Material is. But I like this one I found at: https://auth0.com/blog/creating-beautiful-apps-with-angular-material/

Angular Material is a User Interface (UI) component library that developers can use in their Angular projects to speed up the development of elegant and consistent user interfaces. Angular Material offers you reusable and beautiful UI components like Cards, Inputs, Data Tables, Datepickers, and much more.

Angular Material Definition

The components in Angular Material are just that, Angular components, just like our Welcome and Vehicles components in FredsCars. We apply the Angular Material components by including their elements and directives in our html as we soon will see.

Installing Angular Material

Navigate to your FredsCars Angular project with the following command:

cd C:\Development\FredsCars\FullStack\Module12\FredsCars

Next run the following command to install Angular Material into the FredsCars Angular project.

ng add @angular/material

You will see a message saying that the node package manager is searching for a compatible version of Angular Material that will work well with your project’s dependencies.

Next you should see a message saying npm found a compatible version.

Next you’ll see a message asking if you would like to proceed. Type ‘Y’.

Next you’ll be asked to choose a theme. Hit Enter to choose Indigo/Pink.

Next type ‘y’ to “set up global Angular Material typography styles.

Next choose “Include and enable animations.

Shortly after you should see that the packages were installed successfuly, and that four files were updated.

The install updated the four files listed in the following ways:

app.module.ts: Add the BrowserAnimationsModule to the imports section.

angular.json: register the CSS for the Angular Material Indigo-theme.

"styles": [
    "@angular/material/prebuilt-themes/indigo-pink.css",
    "src/styles.css"
],

index.html:

* remove margins from body.

* Set height to 100% on html and body.

* Set Roboto as the default application font.

* Add a Style Sheet link to Angular Material Icons.

View Angular Material Typography Styles

If you recall back in chapter one when we were first learning CSS and Bootstrap, once we installed Bootstrap the font immediately changed from the browser defaults to the Bootstrap styles for text, headings and so forth. Angular Material is very similar. Now that we have it installed in our FredsCars Angular project, lets restart the project and take a look.

Before we installed Angular Material, this is what our Welcome page looked like.


And after the install this is what it looks like.


I think the font here is much improved, maybe even better than Bootstrap. And, just like when we use Bootstrap we now have a similar issue to fix. Their is no padding on the left and top of the content. Let’s fix that real quick before moving on.

Give me some space!

Open the app.component.css file in the FredsCars/src/app folder and add the following code.

FredsCars\src\app\app.component.css

.container {
  padding: 20px 10px 20px 10px;
}

We are adding 20 pixels of padding to the top and bottom of the content below the nav section and 10 pixels of padding to the left and right.

The results should look similar to the image below.

What’s Next

In this module we installed Angular Material and took a look at what files are modified in the process. In the next module we will improve the look of the Nav Bar by using our first Angular Material Component: MatToolBar

< Prev
Next >

Leave a ReplyCancel reply

Chapter 1: Static HTML – Designing the landing page.

  • Static HTML – Designing the landing page.
  • Let’s get started!
  • Mock your site with HTML
  • Make CSS easy with Bootstrap
  • Mock your content
  • Introducing JavaScript
  • JavaScript Code Improvements
  • Results Data
  • Images and the HTML Image Element.
  • Revisiting Reusability for CSS and JavaScript
  • Reuse for HTML: PART 1
  • Reuse for HTML: PART 2
  • Details Page – Using a Bootstrap Component
  • Creating Links
  • Chapter One Conclusion

Chapter 2: ASP.Net Core – Let’s talk Dynamic

  • Introduction to ASP.Net Core
  • What is .Net?
  • What is ASP.Net
  • Introduction to Entity Framework Core

Chapter 3: ASP.Net MVC Core – Models, Views, and Controllers [ASP.Net Core v9]

  • Introduction to ASP.Net Core MVC
  • Create the project: ASP.Net Core MVC
  • Explore the ASP.Net Core Empty Web Project Template
  • Configure the Application for MVC
  • Create a Controller: Home Controller
  • Create a View: Index View for the Home Controller
  • Install Bootstrap using Libman
  • Create the Layout template
  • Create the Model
  • Install EF Core & Create the Database
  • Seed the Database: Loading test data
  • DI (Dependency Injection): Display a List of Vehicles
  • Repository Pattern: The Vehicles Repo
  • Unit Test 1: Home Controller Can Use Vehicle Repository
  • Unit Test 2: Vehicle Repository Can Return List
  • Add the ImagePath Migration and Thumbnail images to results
  • Pagination: Create a Custom Tag Helper
  • Sorting
  • Category Filter
  • Partial View: Break out the vehicle results
  • View Component: Create dynamic category buttons
  • Create the Details page
  • Create the Create Page
  • Create the Update Page
  • Create the Delete Page
  • Validation
  • Logging & Configuration
  • Storing Secrets
  • Error Handling
  • Security & Administration

Chapter 7: Using Server Side & Client Side technologies together. [ASP.Net Core v7 & Angular v15]

  • Intro to Full Stack Development
  • Fred’s Cars – Full Stack Development
  • Prepare the environment
  • Create the Visual Studio Solution
  • Add the ASP.Net Core Web API project
  • Add the Angular Project
  • Wire it up!
  • WeatherForecast: Understanding the basics
  • Vehicles API Controller: Mock Data
  • Vehicles Angular Component: Consuming Data
  • Routing and Navigation
  • Using a Component Library: Angular Material
  • Our first Angular Material Component: MatToolbar
  • Configuring for Saas: CSS with superpowers
  • Create the Header & Footer components
  • Displaying Results with MatTable
  • Loading: Using a Progress Spinner
  • MatTable: Client-Side Paging and Sorting
  • MatSidenav: Create a Search Sidebar
  • MatCheckbox: Category Search UI
  • Adding an image to the welcome page
  • Create the database with Entity Framework Core migrations
  • MatPaginator & PageEvent: Custom Server-Side Paging
  • Unit Testing: Custom Server-Side Paging
  • Repository Pattern: VehicleRepository
  • Unit Test: Paging in the Vehicles controller
  • Server-Side Sorting
  • Unit Tests: Sorting
  • Filter (Quick Search)
  • Unit Tests: Filter feature
  • Advanced Search: Categories
  • Unit Tests: Search by category
  • Progress Spinner: Final Fix

TOC

  • What were WebForms?
  • Enter MVC
    • Understanding MVC
    • Advantages of MVC
  • ASP.Net Core MVC – A total rewrite
  • ASP.Net Core 2 MVC – Here come Razor Pages
    • Understanding Razor Pages
  • ASP.Net Core 3 – Dropping the MVC reference
    • Understanding Blazor
  • Dropping the MVC reference
  • Hello .Net 5!
  • What’s Next? – Here comes .Net 6.

Recent Posts

  • Angular Commands Cheat Sheet
  • Installing Git for Windows
  • Installing Postman
  • Installing SQL Server 2022 Express
  • Installing Visual Studio 2022

Recent Comments

No comments to show.

Archives

  • November 2023
  • October 2023
  • June 2023
  • October 2021

Categories

  • Angular
  • ASP.Net
  • Environment Setup
  • See All
  • SQL Server
  • Visual Studio
  • Web API & Rest Services

WordPress Theme Editor

Copyright © 2025 Web Development School.

Powered by PressBook Blog WordPress theme