Skip to content

Typography

Font size classes set both font-size (in rem) and line-height together.

Font weight classes are scoped to text elements to avoid unintentional inheritance. This means, if you prefer, you can simply use bold instead of font-bold on text elements without the text prefix

Sass mixins

MixinCSS properties
text($name)font-size, line-height
font($name)font-weight
font-weight($name)font-weight
font-size($name)font-size, line-height
font-family($name)font-family
tracking($name)letter-spacing
leading($name)line-height
italicfont-style: italic
not-italicfont-style: normal

Responsive range mixins

Pass a base value followed by named breakpoint overrides, such as crayon.text-size-range("base", $md: "lg", $lg: "2xl").

MixinPurpose
text-size-range($base, $responsive...)Responsive font size and line height
text-weight-range($base, $responsive...)Responsive font weight
text-leading-range($base, $responsive...)Responsive line height
text-tracking-range($base, $responsive...)Responsive letter spacing

Utility classes

Font Size

ClassProperty
text-xsfont-size: 0.75rem; line-height: 1rem
text-smfont-size: 0.875rem; line-height: 1.25rem
text-basefont-size: 1rem; line-height: 1.5rem
text-lgfont-size: 1.125rem; line-height: 1.75rem
text-xlfont-size: 1.25rem; line-height: 1.75rem
text-2xlfont-size: 1.5rem; line-height: 2rem
text-3xlfont-size: 1.875rem; line-height: 2.25rem
text-4xlfont-size: 2.25rem; line-height: 2.5rem
text-5xlfont-size: 3rem; line-height: 1
text-6xlfont-size: 3.75rem; line-height: 1
text-7xlfont-size: 4.5rem; line-height: 1
text-8xlfont-size: 6rem; line-height: 1
text-9xlfont-size: 8rem; line-height: 1

Scoped Font Weight

ClassProperty inside text elements
thinfont-weight: 100
extralightfont-weight: 200
lightfont-weight: 300
normalfont-weight: 400
mediumfont-weight: 500
semiboldfont-weight: 600
boldfont-weight: 700
extraboldfont-weight: 800
blackfont-weight: 900

Global Font Weight

ClassProperty
font-thinfont-weight: 100
font-extralightfont-weight: 200
font-lightfont-weight: 300
font-normalfont-weight: 400
font-mediumfont-weight: 500
font-semiboldfont-weight: 600
font-boldfont-weight: 700
font-extraboldfont-weight: 800
font-blackfont-weight: 900

Font Family

ClassProperty
font-sansfont-family: sans-serif
font-seriffont-family: Georgia, "Times New Roman", serif
font-monofont-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", "Liberation Mono", Menlo, Monaco, Consolas, monospace

Font Style

ClassProperty inside text elements
italicfont-style: italic
not-italicfont-style: normal

Letter Spacing

ClassProperty
tracking-tighterletter-spacing: -0.05em
tracking-tightletter-spacing: -0.025em
tracking-normalletter-spacing: 0em
tracking-wideletter-spacing: 0.025em
tracking-widerletter-spacing: 0.05em
tracking-widestletter-spacing: 0.1em

Line Height

ClassProperty
leading-noneline-height: 1
leading-tightline-height: 1.25
leading-snugline-height: 1.375
leading-normalline-height: 1.5
leading-relaxedline-height: 1.625
leading-looseline-height: 2

Examples

Mixins

scss
@use "crayon-css" as crayon;

.page-title {
  @include crayon.text("4xl");
  @include crayon.font("bold");
}

.supporting-copy {
  @include crayon.text("sm");
  @include crayon.font("light");
  @include crayon.italic;
}
sass
@use "crayon-css" as crayon

.page-title
  +crayon.text("4xl")
  +crayon.font("bold")

.supporting-copy
  +crayon.text("sm")
  +crayon.font("light")
  +crayon.italic

Utility classes

html
<!-- Font size and line height -->
<p class="text-base">Base body text</p>
<p class="text-sm">Small body text</p>
<h1 class="text-4xl">Large heading</h1>

<!-- Global font weight classes -->
<p class="font-bold">Bold text</p>
<span class="font-semibold">Semibold text</span>
<p class="font-light">Light text</p>

<!-- Scoped style classes work inside text elements -->
<p><span class="italic">Italic text</span></p>
<p><span class="not-italic">Normal text</span></p>

Sass functions

scss
@use "crayon-css" as crayon;

.page-title {
  font-family: crayon.font-family("sans");
  font-size: crayon.font-size("4xl");
  font-weight: crayon.font-weight("bold");
  line-height: crayon.leading("tight");
}

.supporting-copy {
  font-size: crayon.font-size("sm");
  font-weight: crayon.font-weight("light");
  letter-spacing: crayon.tracking("wide");
}
sass
@use "crayon-css" as crayon

.page-title
  font-family: crayon.font-family("sans")
  font-size: crayon.font-size("4xl")
  font-weight: crayon.font-weight("bold")
  line-height: crayon.leading("tight")

.supporting-copy
  font-size: crayon.font-size("sm")
  font-weight: crayon.font-weight("light")
  letter-spacing: crayon.tracking("wide")

CSS Variables

html
<style>
  .page-title {
    font-family: var(--font-sans);
    font-size: var(--text-4xl);
    font-weight: var(--font-weight-bold);
    line-height: var(--leading-tight);
  }

  .supporting-copy {
    font-size: var(--text-sm);
    font-weight: var(--font-weight-light);
    letter-spacing: var(--tracking-wide);
  }
</style>