A "mat-card" is a component provided by Angular Material, primarily used for creating structured and visually appealing containers to display content or information. These cards are commonly employed in web applications to present various types of data, such as text, images, buttons, and other interactive elements, in an organized and consistent manner.
Key features of mat cards typically include:
Card Structure: Mat cards have a card-like structure, often with rounded corners, creating a visually distinct and organized presentation of content.
Content Containers: These cards can house a variety of content, such as text, images, icons, buttons, and other Angular Material components, making them versatile for displaying different types of information.
Header and Footer: Mat cards often come with header and footer sections where you can add titles, subtitles, action buttons, or any other relevant content to the card.
Elevation and Shadow: Mat cards typically have subtle elevation and shadow effects, giving them a tactile appearance and making them stand out from the background.
Interactive Elements: You can include interactive elements within mat cards, such as buttons, links, or form controls, allowing users to interact with or take actions related to the card's content.
Custom Styling: Angular Material provides theming and styling options to customize the appearance of mat cards to match your application's design and branding.
We've previously covered the utilization of a fundamental mat card in the component usageand alsoexplore the process of customizing the card within the Card.
We established a mixin named "theme-mat-card" in "_mat-card.scss" situated within the "mat-themes" folder. Subsequently, this "_mat-card.scss" was imported into the "includes.scss" file.
_mat-card.scss
@use"@angular/material"as mat;@use'sass:map';@use'./theme-palettes/index'as *;// @use './palette' as *;@mixintheme-mat-card($theme) {// Get the color config from the theme. $color-config:mat.get-color-config($theme);// Get the primary color palette from the color-config. $primary:map.get($color-config,'primary'); $accent:map.get($color-config,'accent'); $warn:map.get($color-config,'warn'); $background:map.get($color-config,'background'); $color-accent:mat.get-color-from-palette($accent); $color-accent-100:mat.get-color-from-palette($accent, 100); --cc-mat-card-title:#{$color-accent}; --cc-mat-card-svg-flower:#{$color-accent}; --cc-mat-card-selected-border:#{$color-accent}; --cc-mat-card-selected-bg:#{$color-accent-100};.mat-card-title {color:mat.get-color-from-palette($accent); }.mat-card-svg-tail{.svg-tail__rc{stroke:var(--cc-mat-card-svg-flower); } }.mat-card.mat-chip-list-wrapper {justify-content:flex-start;margin:0; }.cardSlick.mat-card {width:20rem; }.mat-card-header-text {overflow:hidden; }.mat-card.member-card:hover {background-color:mat.get-color-from-palette($accent, 500) !important;color:mat.get-color-from-palette($accent, 500-contrast); }}[layout='v2-type4'] {.mat-card{cursor:pointer;position:relative;border-radius:1.5rem;box-shadow:var(--sbt-box-shadow-6px) !important;overflow:hidden;width:100%;height:100%;display:flex;padding:0;flex-direction:column;.mat-card-header {display:block;z-index:2;order:2;width:100%;justify-content:space-between;padding:0 1rem;margin-bottom:0 !important;.mat-card-avatar {width:4.5rem;height:4.5rem;border-radius:50%;position:absolute;top:3rem;right:2rem;border:0.1875rem solid var(--cc-mat-card-avatar-border);z-index:1;img {position:absolute;left:50%;top:50%;transform:translate(-50%,-50%); }html[dir='rtl'] & {right:auto;left:2rem; } }.mat-card-header-text{margin:0;width:100%; }.mat-card-title{width:70%; } }.mat-card-banner{height:4.5rem;border-radius:1rem;overflow:hidden;margin:1rem;img{width:100%;height:100%;object-fit:cover;margin:0; } }.mat-card-content {order:3;margin:0 !important; }.mat-card-info{padding:0 1rem 1rem; }.mat-card-chips-list{padding:0 1rem; }.mat-card__type {top:2.625rem;left:0;margin:0 !important;html[dir='rtl'] & {right:0;left:unset; }&::before {left:auto !important;html[dir='rtl'] & {left:-0.5rem!important;transform:rotatex(180deg);right:unset; } } }&.selected{border-radius:1.5rem; }&.recently-viewed{.mat-card-header.mat-card-avatar{height:5.5rem;width:5.5rem;right:2.5rem; } }&:hover{transform:translate(0);box-shadow:0 0.125rem 0.4375rem 0 rgba(var(--rc-rgba-black),.16) !important; } }}
includes.scss
@import'./mat-card';
A mixin was crafted and then imported into the "themes.scss" file within the "app-themes" section.