Loading...
Loading...
Material Design 3 (Material You) design system knowledge for modern web and Angular applications. Use when implementing Material Design 3 theming, components, typography, color systems, dynamic color, accessibility patterns, or migrating from Material Design 2. Covers design tokens, theming APIs, and Material You principles.
npx skill4agent add neversight/skills_feed material-design-3primary-containeron-primary-container// Define your theme using M3 tokens
@use '@angular/material' as mat;
// Include core Material Design 3 styles
@include mat.core();
// Define your color palette
$my-primary: mat.define-palette(mat.$azure-palette);
$my-accent: mat.define-palette(mat.$blue-palette);
$my-warn: mat.define-palette(mat.$red-palette);
// Create the theme
$my-theme: mat.define-theme((
color: (
theme-type: light,
primary: $my-primary,
tertiary: $my-accent,
),
typography: (
brand-family: 'Roboto',
bold-weight: 700
),
density: (
scale: 0
)
));
// Apply the theme
@include mat.all-component-themes($my-theme);
// Dark theme variant
$my-dark-theme: mat.define-theme((
color: (
theme-type: dark,
primary: $my-primary,
tertiary: $my-accent,
)
));
// Apply dark theme when needed
.dark-theme {
@include mat.all-component-colors($my-dark-theme);
}// Access theme colors in your components
.my-component {
background-color: var(--mat-sys-primary);
color: var(--mat-sys-on-primary);
&:hover {
background-color: var(--mat-sys-primary-container);
color: var(--mat-sys-on-primary-container);
}
}
// Surface variants
.surface {
background-color: var(--mat-sys-surface);
color: var(--mat-sys-on-surface);
}
.surface-container {
background-color: var(--mat-sys-surface-container);
}// Using typography tokens
.heading {
font: var(--mat-sys-headline-large);
}
.body-text {
font: var(--mat-sys-body-medium);
}
.label {
font: var(--mat-sys-label-small);
}.elevated-card {
// Level 1 elevation
box-shadow: var(--mat-sys-level1);
&:hover {
// Level 2 elevation on hover
box-shadow: var(--mat-sys-level2);
}
}// Example: Dynamic theme switching in Angular
export class ThemeService {
private isDark = signal(false);
toggleTheme() {
this.isDark.update(dark => !dark);
document.body.classList.toggle('dark-theme', this.isDark());
}
applyCustomColors(sourceColor: string) {
// Generate M3 palette from source color
const palette = this.generateM3Palette(sourceColor);
this.applyCSSVariables(palette);
}
}@Component({
selector: 'app-custom-button',
template: `
<button class="m3-button" [class.filled]="variant === 'filled'">
<ng-content></ng-content>
</button>
`,
styles: [`
.m3-button {
padding: 10px 24px;
border-radius: var(--mat-sys-corner-full);
font: var(--mat-sys-label-large);
border: none;
cursor: pointer;
&.filled {
background-color: var(--mat-sys-primary);
color: var(--mat-sys-on-primary);
&:hover {
background-color: var(--mat-sys-primary-container);
color: var(--mat-sys-on-primary-container);
}
}
&.outlined {
background-color: transparent;
border: 1px solid var(--mat-sys-outline);
color: var(--mat-sys-primary);
}
}
`]
})
export class CustomButtonComponent {
@Input() variant: 'filled' | 'outlined' = 'filled';
}| Issue | Solution |
|---|---|
| Colors not applying | Ensure |
| Theme tokens undefined | Check Angular Material version (requires v15+) |
| Dark theme not working | Verify |
| Custom colors not working | Use |
| Typography not loading | Include Material Design fonts (Roboto) in index.html |
| Accessibility contrast issues | Use Material's built-in color roles instead of custom colors |
/.github/skills/material-design-3/SKILL.md~/.github/skills/material-design-3/SKILL.md