define-typography-level
在源代码中有以下定义:
代码变更:
// `font-size`, `line-height`, `font-weight`, `font-family`, and `letter-spacing`.
$my-custom-typography-config: mat.define-typography-config(
$caption:
mat.define-typography-level(
$font-size: 24px,
$line-height: 24px,
$font-weight: 400,
$font-family: Helvetica,
$letter-spacing: normal,
),
);
@include mat.tooltip-typography($my-custom-typography-config);
typography.md
## Typography levels
A **typography level** is a collection of typographic styles that corresponds to a specific
part of an application's structure, such as a header. Each level includes styles for font family,
font weight, font size, and letter spacing. Angular Material uses the [typography levels
from the 2018 version of the Material Design specification][2018-typography], outlined in the
table below.
| Name | Description |
|-----------------|--------------------------------------------------------------|
| `headline-1` | One-off header, usually at the top of the page (e.g. a hero header). |
| `headline-2` | One-off header, usually at the top of the page (e.g. a hero header). |
| `headline-3` | One-off header, usually at the top of the page (e.g. a hero header). |
| `headline-4` | One-off header, usually at the top of the page (e.g. a hero header). |
| `headline-5` | Section heading corresponding to the `<h1>` tag. |
| `headline-6` | Section heading corresponding to the `<h2>` tag. |
| `subtitle-1` | Section heading corresponding to the `<h3>` tag. |
| `subtitle-2` | Section heading corresponding to the `<h4>` tag. |
| `body-1` | Base body text. |
| `body-2` | Secondary body text. |
| `caption` | Smaller body and hint text. |
| `button` | Buttons and anchors. |
[2018-typography]: https://m2.material.io/design/typography/the-type-system.html#type-scale
### Define a level
You can define a typography level with the `define-typography-level` Sass function. This function
accepts, in order, CSS values for `font-size`, `line-height`, `font-weight`, `font-family`, and
`letter-spacing`. You can also specify the parameters by name, as demonstrated in the example below.
```scss
@use '@angular/material' as mat;
$my-custom-level: mat.define-typography-level(
$font-family: Roboto,
$font-weight: 400,
$font-size: 1rem,
$line-height: 1,
$letter-spacing: normal,
);
```
Stackblitz Demo