Skip to content

Typography

Typography mixins for text styling and font management.

h()

Applies typographic styles to an element from a headings map.

ParameterTypeDefault ValueDescription
$tstring-The name of the heading element
$titlesmap$headingsThe headings map to use
scss
h1 {
    @include h(h1);
}
css
h1 {
    font-size: 2.4rem;
    font-weight: bold;
    line-height: 1.2;
}

fontfaces()

Generates @font-face declarations for web fonts.

ParameterTypeDefault ValueDescription
$webfontslist-List of font configurations
$dirstring-Directory path for font files
scss
@include fontfaces((("Roboto", "roboto-regular", 400, normal)), "/fonts/");
css
@font-face {
    font-family: "Roboto";
    src:
        url("/fonts/roboto-regular.woff2") format("woff2"),
        url("/fonts/roboto-regular.woff") format("woff");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

selection()

Styles text selection.

scss
@include selection {
    background-color: yellow;
    color: black;
}
css
::selection {
    text-shadow: none;
    background-color: yellow;
    color: black;
}

ellipsis()

Creates text ellipsis for overflowing text.

scss
.text {
    @include ellipsis();
}
css
.text {
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

hyphenate()

Enables automatic hyphenation for long words.

scss
.text {
    @include hyphenate();
}
css
.text {
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}

underline()

Creates an underline effect with customizable styling.

ParameterTypeDefault ValueDescription
$line-displaystringnoneThe display value for the underline
$color-linecolor$color-lightThe color of the underline
$paddingnumber2emThe padding around the underline
$margin-bottomnumber0.4emThe bottom margin of the underline
scss
.link {
    @include underline(block, #333, 1em, 0.2em);
}
css
.link:after {
    display: block;
    content: " ";
    position: absolute;
    height: 1px;
    background-color: #333;
    left: 1em;
    bottom: 0.2em;
    right: 1em;
}

antialiased()

Applies better font rendering for smoother text.

scss
.text {
    @include antialiased();
}
css
.text {
    -webkit-font-smoothing: antialiased;
    -moz-font-smoothing: antialiased;
    font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -moz-osx-font-smoothing: antialiased;
}