Skip to content

Commit a41f866

Browse files
authored
docs(material/core): show typography as part of the theme (#21810)
also recommend the mdc typography for the mdc components
1 parent cdb2326 commit a41f866

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

Diff for: guides/theming.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ $candy-app-theme: mat-light-theme((
9696
primary: $candy-app-primary,
9797
accent: $candy-app-accent,
9898
warn: $candy-app-warn,
99-
)
99+
),
100+
typography: mat-typography-config(),
101+
density: 0, // Defaults to 0 if omitted, but shown for completeness.
100102
));
101103

102104
// Include theme styles for core and each component used in your app.
@@ -155,7 +157,8 @@ $candy-app-theme: mat-light-theme((
155157
color: (
156158
primary: $candy-app-primary,
157159
accent: $candy-app-accent,
158-
)
160+
),
161+
typography: mat-typography-config()
159162
));
160163

161164
// Include the default theme styles (color and default density)
@@ -242,7 +245,8 @@ $candy-app-theme: mat-light-theme((
242245
color: (
243246
primary: $candy-app-primary,
244247
accent: $candy-app-accent,
245-
)
248+
),
249+
typography: mat-typography-config()
246250
));
247251

248252
// Include the theme styles for only specified components.

Diff for: guides/typography.md

+10-8
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ creating a custom theme, you can create a custom **typography configuration**.
6767

6868
// Define a custom typography config that overrides the font-family as well as the
6969
// `headlines` and `body-1` levels.
70-
$custom-typography: mat-typography-config(
71-
$font-family: 'Roboto, monospace',
72-
$headline: mat-typography-level(32px, 48px, 700),
73-
$body-1: mat-typography-level(16px, 24px, 500)
70+
$custom-typography-theme: (
71+
typography: mat-typography-config(
72+
$font-family: 'Roboto, monospace',
73+
$headline: mat-typography-level(32px, 48px, 700),
74+
$body-1: mat-typography-level(16px, 24px, 500)
75+
)
7476
);
7577
```
7678

@@ -86,21 +88,21 @@ different Sass mixins.
8688

8789
```scss
8890
// Override typography CSS classes (e.g., mat-h1, mat-display-1, mat-typography, etc.).
89-
@include mat-base-typography($custom-typography);
91+
@include mat-base-typography($custom-typography-theme);
9092

9193
// Override typography for a specific Angular Material components.
92-
@include mat-checkbox-typography($custom-typography);
94+
@include mat-checkbox-typography($custom-typography-theme);
9395

9496
// Override typography for all Angular Material, including mat-base-typography and all components.
95-
@include angular-material-typography($custom-typography);
97+
@include angular-material-typography($custom-typography-theme);
9698
```
9799

98100
If you're using Material's theming, you can also pass in your typography config to the
99101
`mat-core` mixin:
100102

101103
```scss
102104
// Override the typography in the core CSS.
103-
@include mat-core($custom-typography);
105+
@include mat-core($custom-typography-theme);
104106
```
105107

106108
For more details about the typography functions and default config, see the

Diff for: src/material-experimental/README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,14 @@ be included in the pre-built CSS mixin and will need to be explicitly included.
6161
color: (
6262
primary: $my-primary,
6363
accent: $my-accent
64-
)
64+
),
65+
// Using `mat-mdc-typography-config` rather than `mat-typography-config` generates a typography
66+
// config directly from the official Material Design styles. This includes using `rem`-based
67+
// measurements rather than `px`-based ones as the spec recommends.
68+
typography: mat-mdc-typography-config(),
69+
// The density level to use in this theme, defaults to 0 if not specified.
70+
density: 0
6571
));
6672

6773
@include angular-material-mdc-theme($my-theme);
68-
@include angular-material-mdc-typography();
6974
```

0 commit comments

Comments
 (0)