Play

Angular Material does not only provide system variables for colors and typography, but also for other properties like shape, and shadow.

Shape

Let’s try to modify the shape of the dialog and buttons & form fields inside the dialog. We want to make them look sharper.

Create a new file _shape.scss in the styles folder and add the following code:

styles/_shape.scss
@use "@angular/material" as mat;
$sharp-radius: 0;
.sharp {
@include mat.theme-overrides(
(
// for mat-buttons
corner-full: $sharp-radius,
// for dialog container
corner-extra-large: $sharp-radius,
// for form fields
corner-extra-small: $sharp-radius
)
);
}

Next, add shape styles in src/styles.scss file.

src/styles.scss
@use "./styles/shape";

And lastly, add the sharp class as panelClass to the dialog.

app.component.ts
@Component({})
export class AppComponent {
openAddTodoDialog(): void {
const dialogRef = this.dialog.open(TodoFormDialogComponent, {
disableClose: true,
panelClass: 'sharp',
});
// rest remains same
}
}

Below is the list of system variables for shape:

  • corner-extra-large
  • corner-extra-large-top
  • corner-extra-small
  • corner-extra-small-top
  • corner-full
  • corner-large
  • corner-large-end
  • corner-large-start
  • corner-large-top
  • corner-medium
  • corner-none
  • corner-small

Shadow

Next, let’s try to modify the shadow of the add todo fab button.

Go to src/app/app.component.scss and add the following code:

app.component.scss
.add-todo-fab {
@include mat.theme-overrides((
level3: 0 4px 6px 1px var(--mat-sys-surface-dim),
));
}

Below is the list of system variables for shadow:

  • level0
  • level1
  • level2
  • level3
  • level4
  • level5
Next arrow_forward Custom Component Styles We will apply Angular Material styles to a custom component.