<h1 class="acl-typography--headline1">Headline 1</h1>
<h1 class="acl-typography--headline1">
<i class="material-icons">fingerprint</i>Headline 1 With Icon
</h1>
<h2 class="acl-typography--headline2">Headline 2</h2>
<h2 class="acl-typography--headline2"><i class="material-icons">gesture</i>Headline 2 With Icon</h2>
<h3 class="acl-typography--headline3">Headline 3</h3>
<h3 class="acl-typography--headline3"><i class="material-icons">account_circle</i>Headline 3 With Icon</h3>
<h4 class="acl-typography--headline4">Headline 4</h4>
<h4 class="acl-typography--headline4"><i class="material-icons">alarm</i>Headline 4 With Icon</h4>
<h5 class="acl-typography--headline5">Headline 5</h5>
<h5 class="acl-typography--headline5"><i class="material-icons">store</i>Headline 5 With Icon</h5>
<h6 class="acl-typography--subtitle1">Subtitle 1</h6>
<h6 class="acl-typography--subtitle2">Subtitle 2</h6>
<p class="acl-typography--body1">Body 1. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quos blanditiis
tenetur unde suscipit, quam beatae rerum inventore consectetur, neque doloribus, cupiditate numquam dignissimos
laborum fugiat deleniti? Eum quasi quidem quibusdam.</p>
<p class="acl-typography--body2">Body 2. Lorem ipsum dolor sit amet consectetur adipisicing elit. Cupiditate aliquid ad
quas sunt voluptatum officia dolorum cumque, possimus nihil molestias sapiente necessitatibus dolor saepe inventore,
soluta id accusantium voluptas beatae.</p>
<h1 class="acl-typography--headline1">Headline 1</h1>
<h1 class="acl-typography--headline1">
<i class="material-icons">fingerprint</i>Headline 1 With Icon</h1>
<h2 class="acl-typography--headline2">Headline 2</h2>
<h2 class="acl-typography--headline2"><i class="material-icons">gesture</i>Headline 2 With Icon</h2>
<h3 class="acl-typography--headline3">Headline 3</h3>
<h3 class="acl-typography--headline3"><i class="material-icons">account_circle</i>Headline 3 With Icon</h3>
<h4 class="acl-typography--headline4">Headline 4</h4>
<h4 class="acl-typography--headline4"><i class="material-icons">alarm</i>Headline 4 With Icon</h4>
<h5 class="acl-typography--headline5">Headline 5</h5>
<h5 class="acl-typography--headline5"><i class="material-icons">store</i>Headline 5 With Icon</h5>
<h6 class="acl-typography--subtitle1">Subtitle 1</h6>
<h6 class="acl-typography--subtitle2">Subtitle 2</h6>
<p class="acl-typography--body1">Body 1. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quos blanditiis
tenetur unde suscipit, quam beatae rerum inventore consectetur, neque doloribus, cupiditate numquam dignissimos
laborum fugiat deleniti? Eum quasi quidem quibusdam.</p>
<p class="acl-typography--body2">Body 2. Lorem ipsum dolor sit amet consectetur adipisicing elit. Cupiditate aliquid ad
quas sunt voluptatum officia dolorum cumque, possimus nihil molestias sapiente necessitatibus dolor saepe inventore,
soluta id accusantium voluptas beatae.</p>
/* No context defined. */
@function acl-typography-get-global-variable_($style) {
@if $style == 'headline1' {
@return $acl-typography-styles-headline1;
} @else if $style == 'headline2' {
@return $acl-typography-styles-headline2;
} @else if $style == 'headline3' {
@return $acl-typography-styles-headline3;
} @else if $style == 'headline4' {
@return $acl-typography-styles-headline4;
} @else if $style == 'headline5' {
@return $acl-typography-styles-headline5;
} @else if $style == 'headline6' {
@return $acl-typography-styles-headline6;
} @else if $style == 'subtitle1' {
@return $acl-typography-styles-subtitle1;
} @else if $style == 'subtitle2' {
@return $acl-typography-styles-subtitle2;
} @else if $style == 'body1' {
@return $acl-typography-styles-body1;
} @else if $style == 'body2' {
@return $acl-typography-styles-body2;
} @else if $style == 'caption' {
@return $acl-typography-styles-caption;
} @else if $style == 'button' {
@return $acl-typography-styles-button;
} @else if $style == 'overline' {
@return $acl-typography-styles-overline;
} @else {
@return ();
}
}
@function acl-typography-set-styles_($base-styles, $scale-styles) {
@each $style, $style-props in $scale-styles {
// Merge base properties for all styles.
$style-props: map-merge($base-styles, $style-props);
// Merge global overrides onto each style.
@if global_variable_exists(unquote('acl-typography-styles-#{$style}')) {
$style-props: map-merge($style-props, acl-typography-get-global-variable_(#{$style}));
}
// Override original styles with new styles.
$scale-styles: map-merge($scale-styles, (#{$style}: $style-props));
}
@return $scale-styles;
}
@function acl-typography-get-letter-spacing_($tracking, $font-size) {
@return $tracking / ($font-size * 16) * 1em;
}
@import '../feature-targeting/functions';
@import '../feature-targeting/mixins';
@import './variables';
@mixin acl-typography-core-styles($query: acl-feature-all()) {
.acl-typography {
@include acl-typography-base($query: $query);
}
@each $style in map-keys($acl-typography-styles) {
.acl-typography--#{$style} {
@include acl-typography($style, $query: $query);
}
}
}
@mixin acl-typography-base($query: acl-feature-all()) {
$feat-typography: acl-feature-create-target($query, typography);
@include acl-feature-targets($feat-typography) {
@each $key, $value in $acl-typography-base {
#{$key}: $value;
}
}
}
@mixin acl-typography($style, $query: acl-feature-all(), $exclude-props: ()) {
$feat-typography: acl-feature-create-target($query, typography);
$style-props: map-get($acl-typography-styles, $style);
@if not map-has-key($acl-typography-styles, $style) {
@error "Invalid style specified! #{$style} doesn't exist. Choose one of #{map-keys($acl-typography-styles)}";
}
@include acl-feature-targets($feat-typography) {
@each $key, $value in $style-props {
@if index($exclude-props, $key) == null {
#{$key}: $value;
}
}
}
}
// Element must be `display: block` or `display: inline-block` for this to work.
@mixin acl-typography-overflow-ellipsis($query: acl-feature-all()) {
$feat-structure: acl-feature-create-target($query, structure);
@include acl-feature-targets($feat-structure) {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
}
@mixin acl-typography-baseline-top($distance, $query: acl-feature-all()) {
$feat-structure: acl-feature-create-target($query, structure);
@include acl-feature-targets($feat-structure) {
display: block;
margin-top: 0;
/* @alternate */
line-height: normal;
}
&::before {
@include acl-feature-targets($feat-structure) {
@include acl-typography-baseline-strut_($distance);
vertical-align: 0;
}
}
}
@mixin acl-typography-baseline-bottom($distance, $query: acl-feature-all()) {
$feat-structure: acl-feature-create-target($query, structure);
@include acl-feature-targets($feat-structure) {
margin-bottom: -1 * $distance;
}
&::after {
@include acl-feature-targets($feat-structure) {
@include acl-typography-baseline-strut_($distance);
vertical-align: -1 * $distance;
}
}
}
@mixin acl-typography-baseline-strut_($distance) {
display: inline-block;
width: 0;
height: $distance;
content: '';
}
@import './functions';
$acl-typography-font-family: unquote('Avenir Next, Helvetica, Arial, sans-serif') !default;
$acl-typography-font-family-semibold: unquote('Avenir Next Semibold, Helvetica, Arial, sans-serif');
$acl-typography-font-family-heading-semibold: unquote('Hero New Semibold, Helvetica, Arial, sans-serif');
$acl-typography-font-family-heading-regular: unquote('Hero New Regular, Helvetica, Arial, sans-serif');
$acl-typography-font-family-heading-medium: unquote('Hero New Medium, Helvetica, Arial, sans-serif');
$acl-typography-font-weight-values: (
thin: 100,
light: 300,
regular: 400,
medium: 500,
semibold: 600,
bold: 700,
black: 900,
) !default;
$acl-typography-styles-headline1: (
font-family: $acl-typography-font-family-heading-semibold,
font-weight: map-get($acl-typography-font-weight-values, semibold),
color: $acl-primary-colour--variant,
);
$acl-typography-styles-headline2: (
font-family: $acl-typography-font-family-heading-semibold,
font-weight: map-get($acl-typography-font-weight-values, semibold),
color: $acl-primary-colour--variant,
);
$acl-typography-styles-headline3: (
font-family: $acl-typography-font-family-heading-semibold,
font-weight: map-get($acl-typography-font-weight-values, semibold),
color: $acl-secondary-colour--varient,
);
$acl-typography-styles-headline4: (
font-family: $acl-typography-font-family-heading-semibold,
font-weight: map-get($acl-typography-font-weight-values, semibold),
color: $acl-secondary-colour--varient,
);
$acl-typography-styles-headline5: (
font-family: $acl-typography-font-family-heading-semibold,
font-weight: map-get($acl-typography-font-weight-values, semibold),
color: $acl-secondary-colour--varient,
);
$acl-typography-styles-subtitle1: (
font-family: $acl-typography-font-family-heading-regular,
font-weight: map-get($acl-typography-font-weight-values, regular),
color: #b1b7cd,
);
$acl-typography-styles-subtitle2: (
font-family: $acl-typography-font-family-heading-regular,
font-weight: map-get($acl-typography-font-weight-values, regular),
color: #b1b7cd,
);
$acl-typography-styles-body1: (
font-weight: map-get($acl-typography-font-weight-values, regular),
color: $acl-primary-colour--variant,
);
$acl-typography-styles-body2: (
font-weight: map-get($acl-typography-font-weight-values, regular),
color: $acl-primary-colour--variant,
);
$acl-typography-base: (
font-family: $acl-typography-font-family,
-moz-osx-font-smoothing: grayscale,
-webkit-font-smoothing: antialiased,
) !default;
$acl-typography-styles: acl-typography-set-styles_(
$acl-typography-base,
(
headline1: (
//font-size: 6rem, // 96sp // Material Orig
font-size: 38px,
line-height: 6rem,
font-weight: map-get($acl-typography-font-weight-values, light),
letter-spacing: acl-typography-get-letter-spacing_(-1.5, 6),
text-decoration: inherit,
text-transform: inherit,
),
headline2: (
//font-size: 3.75rem, // 60sp // Material Orig
font-size: 28px,
line-height: 3.75rem,
font-weight: map-get($acl-typography-font-weight-values, light),
letter-spacing: acl-typography-get-letter-spacing_(-0.5, 3.75),
text-decoration: inherit,
text-transform: inherit,
),
headline3: (
//font-size: 3rem, // 48sp // Material Orig
font-size: 24px,
line-height: 3.125rem,
// 50sp
font-weight: map-get($acl-typography-font-weight-values, regular),
letter-spacing: normal,
text-decoration: inherit,
text-transform: inherit,
),
headline4: (
//font-size: 2.125rem, // 34sp // Material Orig
font-size: 18px,
line-height: 2.5rem,
// 40sp
font-weight: map-get($acl-typography-font-weight-values, regular),
letter-spacing: acl-typography-get-letter-spacing_(0.25, 2.125),
text-decoration: inherit,
text-transform: inherit,
),
headline5: (
//font-size: 1.5rem, // 24sp // Material Orig
font-size: 14px,
line-height: 2rem,
// 32sp
font-weight: map-get($acl-typography-font-weight-values, regular),
letter-spacing: normal,
text-decoration: inherit,
text-transform: inherit,
),
headline6: (
//font-size: 1.25rem, // 20sp // Material Orig
font-size: 18px,
line-height: 2rem,
// 32sp
font-weight: map-get($acl-typography-font-weight-values, medium),
letter-spacing: acl-typography-get-letter-spacing_(0.25, 1.25),
text-decoration: inherit,
text-transform: inherit,
),
subtitle1: (
//font-size: 1rem, // 16sp // Material Orig
font-size: 18px,
line-height: 1.75rem,
// 28sp
font-weight: map-get($acl-typography-font-weight-values, regular),
letter-spacing: acl-typography-get-letter-spacing_(0.15, 1),
text-decoration: inherit,
text-transform: inherit,
),
subtitle2: (
//font-size: .875rem, // 14sp // Material Orig
font-size: 14px,
line-height: 1.375rem,
// 22sp
font-weight: map-get($acl-typography-font-weight-values, medium),
letter-spacing: acl-typography-get-letter-spacing_(0.1, 0.875),
text-decoration: inherit,
text-transform: inherit,
),
body1: (
//font-size: 1rem, // 16sp
font-size: 18px,
line-height: 1.5rem,
// 24sp
font-weight: map-get($acl-typography-font-weight-values, regular),
letter-spacing: acl-typography-get-letter-spacing_(0.5, 1),
text-decoration: inherit,
text-transform: inherit,
),
body2: (
//font-size: .875rem, // 14sp // // Material Orig
font-size: 16px,
line-height: 1.25rem,
// 20sp
font-weight: map-get($acl-typography-font-weight-values, regular),
letter-spacing: acl-typography-get-letter-spacing_(0.25, 0.875),
text-decoration: inherit,
text-transform: inherit,
),
caption: (
font-size: 0.75rem,
// 12sp
line-height: 1.25rem,
// 20sp
font-weight: map-get($acl-typography-font-weight-values, regular),
letter-spacing: acl-typography-get-letter-spacing_(0.4, 0.75),
text-decoration: inherit,
text-transform: inherit,
),
button: (
//font-size: .875rem, // 14sp // Material Orig
font-size: 18px,
line-height: 2.25rem,
// 36sp
font-weight: map-get($acl-typography-font-weight-values, medium),
letter-spacing: acl-typography-get-letter-spacing_(1.25, 0.875),
text-decoration: none,
text-transform: uppercase,
),
overline: (
font-size: 0.75rem,
// 12sp
line-height: 2rem,
// 32sp
font-weight: map-get($acl-typography-font-weight-values, medium),
letter-spacing: acl-typography-get-letter-spacing_(2, 0.75),
text-decoration: none,
text-transform: uppercase,
),
)
) !default;
@import './mixins';
@import './variables';
@include acl-typography-core-styles;
.acl-typography {
&--no-margin {
margin: 0;
}
&--bottom-margin {
margin-top: 0;
}
&--top-margin {
margin-bottom: 0;
}
&--bold {
font-weight: bold;
}
}
Material Design’s text sizes and styles were developed to balance content density and reading comfort under typical usage conditions.
MDC Typography is a foundational module that applies these styles to MDC Web components. The typographic styles in this module are derived from thirteen styles:
npm install ..//typographyWe recommend using Roboto from Google Fonts:
<head>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
</head>
<body class="acl-typography">
<h1 class="acl-typography--headline1">Big header</h1>
</body>@import "../typography/acl-typography";Some components have a set typographic style. For example, a raised MDC Card uses Body 1, Body 2, and Headline styles.
If you want to set the typographic style of an element, which is not a Material Design component, you can apply the following CSS classes.
| CSS Class | Description |
|---|---|
acl-typography |
Sets the font to Roboto |
acl-typography--headline1 |
Sets font properties as Headline 1 |
acl-typography--headline2 |
Sets font properties as Headline 2 |
acl-typography--headline3 |
Sets font properties as Headline 3 |
acl-typography--headline4 |
Sets font properties as Headline 4 |
acl-typography--headline5 |
Sets font properties as Headline 5 |
acl-typography--headline6 |
Sets font properties as Headline 6 |
acl-typography--subtitle1 |
Sets font properties as Subtitle 1 |
acl-typography--subtitle2 |
Sets font properties as Subtitle 2 |
acl-typography--body1 |
Sets font properties as Body 1 |
acl-typography--body2 |
Sets font properties as Body 2 |
acl-typography--caption |
Sets font properties as Caption |
acl-typography--button |
Sets font properties as Button |
acl-typography--overline |
Sets font properties as Overline |
| Mixin | Description |
|---|---|
acl-typography-base |
Sets the font to Roboto |
acl-typography($style) |
Applies one of the typography styles, including setting the font to Roboto |
acl-typography-overflow-ellipsis |
Truncates overflow text to one line with an ellipsis |
acl-typography-baseline-top($distance) |
Sets the baseline height of a text element from top. |
acl-typography-baseline-bottom($distance) |
Sets the distance from text baseline to bottom. This mixin should be combined with acl-typography-baseline-top when setting baseline distance to following text element. |
A note about
acl-typography-overflow-ellipsis,acl-typography-overflow-ellipsisshould only be used if the element isdisplay: blockordisplay: inline-block.
$style ValuesThese styles can be used as the $style argument for the acl-typography mixin.
headline1headline2headline3headline4headline5headline6subtitle1subtitle2body1body2captionbuttonoverlineAll styles can be overridden using Sass global variables before the component is imported by setting a global
variable named $acl-typography-styles-{style}. The variable should be assigned a map that contains all the properties
you want to override for a particular style.
Example: Overriding the button font-size and text-transform properties.
$acl-typography-styles-button: (
font-size: 16px,
text-transform: none,
);
@import "../button/acl-button";Example: Overriding the global font-family property.
$acl-typography-font-family: unquote("Arial, Helvetica, sans-serif");
...
@import ...Example: Overriding the font-family property for headline1 and font-family and font-size for headline2.
$acl-typography-styles-headline1: (
font-family: unquote("Arial, Helvetica, sans-serif")
);
$acl-typography-styles-headline2: (
font-family: unquote("Arial, Helvetica, sans-serif"),
font-size: 3.25rem
);
...
@import ...