Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
$m-break: 56.25rem; //900px

$base-font-size: 1rem; // 1rem = 16px
$font-scale: 1.25; // Major Third
$font-scale-mobile: 1.125; // Major Second

$font-size-sm: $base-font-size / $font-scale; // 13px;

// Function to calculate power
@function pow($exponent) {
  $value: 1;

  @if $exponent > 0 {
    @for $i from 1 through $exponent {
      $value: $value * $font-scale;
    }
  }

  @return $value;
}

//Function to calculate power for mobile
@function m-pow($exponent) {
  $value: 1;

  @if $exponent > 0 {
    @for $i from 1 through $exponent {
      $value: $value * $font-scale-mobile;
    }
  }

  @return $value;
}

h6 {
  font-size: $base-font-size; //16px
}

h5 {
  font-size: clamp($base-font-size *m-pow(1);, 
  @include breakpoint($m-break) {
    font-size: 1vw, $base-font-size *pow(1); //20px
  });
} 

h4 {
  font-size: clamp($base-font-size *m-pow(2);, 
  @include breakpoint($m-break) {
    font-size: 2vw, $base-font-size *pow(2)); //25px

 }
}

h3 {
  font-size: clamp($base-font-size *m-pow(3);, 
  @include breakpoint($m-break) {
    font-size: 3vw, $base-font-size *pow(3));
//31px
  }
}

h2 {
  font-size: clamp($base-font-size *m-pow(4);
  @include breakpoint($m-break) {
    font-size: , 4vw, $base-font-size *pow(4)); //39px
  }
}

h1 {
  font-size: clamp($base-font-size *m-pow(5);, 
  @include breakpoint($m-break) {
    font-size: 5vw, $base-font-size *pow(5));
//48px
  }
}

The $base-font-size doesn’t need to limit to px, it can be rem em or ex.

...

Info

Small scales (less than 1.2) are subtle and good for both mobile and desktop apps, or the mobile version of a responsive site.

Medium scales (1.15–1.333) have a clear hierarchy, and help to organize sections with subheadings. A medium scale is versatile and works well for a wide variety of desktop sites, including blogs and marketing sites.

Large scales (1.333 or greater) may be challenging to implement effectively, but could work well for portfolios, agencies, some marketing sites, or avant-garde works.

More things to consider:

...

  • Line-height based on modular scale method?

  • Letter spacing?Minimal font size?

Reference:

Typographic Scales - Consistent typography using simple math https://spec.fm/specifics/type-scale

...