angular-material

Angular Material - Quick Reference

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "angular-material" with this command: npx skills add claude-dev-suite/claude-dev-suite/claude-dev-suite-claude-dev-suite-angular-material

Angular Material - Quick Reference

Deep Knowledge: Use mcp__documentation__fetch_docs with technology: angular for Material documentation.

Setup

// app.config.ts import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';

export const appConfig: ApplicationConfig = { providers: [provideAnimationsAsync()], };

Common Components

Table with Sorting and Pagination

import { Component, signal, ViewChild } from '@angular/core'; import { MatTableModule, MatTableDataSource } from '@angular/material/table'; import { MatSortModule, MatSort } from '@angular/material/sort'; import { MatPaginatorModule, MatPaginator } from '@angular/material/paginator';

@Component({ standalone: true, imports: [MatTableModule, MatSortModule, MatPaginatorModule], template: &#x3C;table mat-table [dataSource]="dataSource" matSort> &#x3C;ng-container matColumnDef="name"> &#x3C;th mat-header-cell *matHeaderCellDef mat-sort-header>Name&#x3C;/th> &#x3C;td mat-cell *matCellDef="let row">{{ row.name }}&#x3C;/td> &#x3C;/ng-container> &#x3C;ng-container matColumnDef="email"> &#x3C;th mat-header-cell *matHeaderCellDef>Email&#x3C;/th> &#x3C;td mat-cell *matCellDef="let row">{{ row.email }}&#x3C;/td> &#x3C;/ng-container> &#x3C;tr mat-header-row *matHeaderRowDef="displayedColumns">&#x3C;/tr> &#x3C;tr mat-row *matRowDef="let row; columns: displayedColumns">&#x3C;/tr> &#x3C;/table> &#x3C;mat-paginator [pageSizeOptions]="[5, 10, 25]" showFirstLastButtons /> }) export class UserTableComponent { displayedColumns = ['name', 'email']; dataSource = new MatTableDataSource<User>([]);

@ViewChild(MatSort) sort!: MatSort; @ViewChild(MatPaginator) paginator!: MatPaginator;

ngAfterViewInit() { this.dataSource.sort = this.sort; this.dataSource.paginator = this.paginator; } }

Dialog

import { MatDialogModule, MatDialog } from '@angular/material/dialog';

// Open dialog @Component({ ... }) export class ParentComponent { private dialog = inject(MatDialog);

openDialog() { const ref = this.dialog.open(ConfirmDialogComponent, { width: '400px', data: { message: 'Are you sure?' }, }); ref.afterClosed().subscribe(result => { if (result) { /* confirmed */ } }); } }

// Dialog component @Component({ standalone: true, imports: [MatDialogModule, MatButtonModule], template: &#x3C;h2 mat-dialog-title>Confirm&#x3C;/h2> &#x3C;mat-dialog-content>{{ data.message }}&#x3C;/mat-dialog-content> &#x3C;mat-dialog-actions align="end"> &#x3C;button mat-button mat-dialog-close>Cancel&#x3C;/button> &#x3C;button mat-flat-button [mat-dialog-close]="true" color="primary">OK&#x3C;/button> &#x3C;/mat-dialog-actions> }) export class ConfirmDialogComponent { data = inject(MAT_DIALOG_DATA); }

Form Fields

import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; import { MatSelectModule } from '@angular/material/select';

@Component({ standalone: true, imports: [MatFormFieldModule, MatInputModule, MatSelectModule, ReactiveFormsModule], template: ` <mat-form-field appearance="outline"> <mat-label>Name</mat-label> <input matInput formControlName="name" /> <mat-error>Name is required</mat-error> </mat-form-field>

&#x3C;mat-form-field appearance="outline">
  &#x3C;mat-label>Role&#x3C;/mat-label>
  &#x3C;mat-select formControlName="role">
    &#x3C;mat-option value="admin">Admin&#x3C;/mat-option>
    &#x3C;mat-option value="user">User&#x3C;/mat-option>
  &#x3C;/mat-select>
&#x3C;/mat-form-field>

` })

Custom Theming

// styles.scss @use '@angular/material' as mat;

$primary: mat.m2-define-palette(mat.$m2-indigo-palette); $accent: mat.m2-define-palette(mat.$m2-pink-palette); $theme: mat.m2-define-light-theme(( color: (primary: $primary, accent: $accent), typography: mat.m2-define-typography-config(), density: 0, ));

@include mat.all-component-themes($theme);

Anti-Patterns

Anti-Pattern Why It's Bad Correct Approach

Importing entire Material module Large bundle Import individual modules

Not using appearance="outline"

Inconsistent UI Standardize form field appearance

Synchronous animations Blocks rendering Use provideAnimationsAsync()

Custom CSS for Material components Breaks updates Use theming API

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

cron-scheduling

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

token-optimization

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

webrtc

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

react-19

No summary provided by upstream source.

Repository SourceNeeds Review