![]() |
VOOZH | about |
Angular Material is a UI component library which is developed by Google so that Angular developers can develop modern applications in a structured and responsive way. By making use of this library, we can greatly increase the user experience of an end-user thereby gaining popularity for our application. This library contains modern ready-to-use elements which can be directly used with minimum or no extra code.
The <mat-card> is a container for the content that can be used to insert the media, text & action in context to the single subject. The basic requirement for design the card is only an <mat-card> element that has some content in it, that will be used to build simple cards.
Syntax:
<mat-card> Content </mat-card>
This element has opening tag followed with the content or some code & ended with the closing tag. Angular Material facilitates the number of preset sections that can be used with the <mat-card> element, which is given below:
Element Name | Description of the Element |
|---|---|
<mat-card-title> | Title of the respective card |
<mat-card-subtitle> | The subtitle of the respective card |
<mat-card-content> | All the data and information which is the body of the card needs to be written in this section. |
<mat-card-actions> | This tag is used to mention all the events like submit, cancel and etc |
<mat-card-header> | It is used to mention all the details on the header of the card like title, subtitle etc. |
| <mat-card-footer> | This section is anchored to the bottom of the card., that contains the copyright symbol with year, company name, etc. |
The above elements are primarily used for pre-styled content containers, instead of using any additional APIs. However, the align property with <mat-card-actions>, is mainly used to position the actions at the 'start' or 'end' of the container.
Installation Syntax:
In order to use the Basic Card Section in the Angular Material, we must have Angular CLI installed in the local machine, that will help to add and configure the Angular material library. After satisfying the required condition, type the following command on the Angular CLI:
ng add @angular/material
Please refer to the Adding Angular Material Component to Angular Application article for the detailed installation procedure.
Project Structure:
After successful installation, the project structure will look like the following:
👁 ImageExample: The below example illustrates the implementation of the Angular Material Card.
Output:
👁 Angular Material Basic Card SectionReference: https://material.angular.dev/components/card/overview#basic-card-sections