@bolt/settings-font-size

0.9.0 • Public • Published

bolt/settings-font-sizes

Fluid, font size settings based on a typographic modular scale. Part of the Bolt “Core” CSS framework that powers the Bolt Design System.


Table of Contents

Cheat Sheet

Install via NPM

npm install @bolt/settings-font-sizes

Font Sizing Chart*

Name Font Size (rems) Min to max font size (px) Line Height
xxxlarge** 2.28rem to 3.08rem 34.20px to 55.44px 1.14
xxlarge 1.78rem 26.70px to 32.04px 1.13
xlarge 1.42rem 21.30px to 25.56px 1.21
large 1.11rem 16.65px to 19.98px 1.31
medium (base) 1.00rem 15.00px to 18.00px 1.65
small 0.90rem 13.50px to 16.20px 1.51
xsmall 0.80rem 12.00px to 14.40px 1.45

*Sizes Rounded to 2 decimal places

**In addition to scaling according to base, xxxlarge has another scaling that takes care of devices with narrow screen.

Base font size range

15px (min) to 18px (max)

To calculate font size in pixels:

Pixel font size = font size (in rems) × responsive font size base

To calculate line-height n pixels:

Pixel line-height = font size in px × unitless line height

[Deprecation Notice]: Coming in from PegaKit? Take note that Bolt’s t-shirt based font size no longer include a base font size in order to standardize how we name things across the board. As a rule of thumb, what was once the default base font size is now medium and any other sizes medium or larger would need to increase by one shirt size.


Getting Started

The best way to start using Bolt is via the Bolt Starterkit (coming soon), a pre-assembled front-end boilerplate designed to get you up and running as quickly as possible.

You can also use the full Bolt Core CSS framework on its own, or, install just the parts you need and fold the different ITCSS layers of Bolt into your existing codebase.

Installing Bolt’s font-size settings is as easy as running NPM install:

npm install @bolt/settings-font-sizes

TIP:: Don’t have a package.json file? Need a little help getting started? Check out our Getting Started guide for some tips to help get you up to speed.

Usage

Once installed, you should @import the main Sass partial into your project’s main .scss file to make the included variables available to the rest of your code.

// Settings
@import ‘@bolt/settings-font-sizes’
...

// Tools
@import ‘@bolt/tools-...’

Since Bolt's CSS architecture is based on ITCSS (Inverted Triangle CSS)1, what Sass partials you import, and in what order, makes a whole world of difference. That’s why importing any Settings packages from Bolt in your project’s Settings layer (prior to any Sass mixins, resets, base HTML element styles, etc) is so important.

Compiling

We recommend using Bolt’s Gulp-based front-end build tools to compile your Sass as we're pre-packaging many of the latest tools and add-ons to help you write your very best: LibSass, Autoprefixer, PostCSS, CleanCSS, Sassdoc, Stylelint, Gulp Plumber, npm-sass, and BrowserSync live reloading.


Font Size Features

The Bolt Design System team has gone through vigorous testing to make sure all types are legible on all devices. We have created the following range of sizes to be used for headings and body text. All font sizes are responsive in relation to device screen size.

Font Sizes Defined as rems vs px 2

Bolt’s font sizes are defined in rems and and are organized in a structured Sass Map for consistency and maintainability.

Rem “represents the font-size of the root element (e.g., the font-size of the element). When used within the root elements font-size, it represents its initial value (common browser default is 16px, but changes based upon users preferences).”
-- - CSS | MDN

Line heights Included 3

Each font size includes two pre-defined unitless line-heights: the default regular line-height for more editorial-focused designs and a tight shorter line height option for more interface-focused designs.

Responsive Ready 4

By defining our font sizes in REMs and by using unit-less line-heights, Bolt’s font sizes are responsive-ready out of the box. This responsive fluid typographic behavior is automatically included in the separate bolt/elements-page package (which gets @imported in the ITCSS elements layer)

/*------------------------------------*\
  HTML + BODY ELEMENTS
\*------------------------------------*/
/**
	* 1. Sets minimum base font size
	* 2. Automatic responsive typopgraphy via viewport units
	* 3. Sets maximum base font size
	*/
html {
  font-size: $bolt-font-size--min-px; /* [1] */

  @include respond-to(medium) {
    font-size: calc(#{$font-size--min-px} + (#{$font-size--max - $font-size--min} * (100vw - #{$breakpoint--min}) / #{strip-unit($breakpoint--max) - strip-unit($breakpoint--min)})); /* [2] */
  }

  @include respond-to(xlarge) {
    font-size: $font-size--max-px; /* [3] */
  }
}

Defined as T-shirt Sizes 5

As with most sizing options in Bolt, font sizes are categorized and referenced as t-shirt sizes, with medium being the default base font size (ie. the font size on the

or tag), with each t-shirt size option being one step larger/smaller in the typographic modular scale.

Further Reading:

1. Learn more about ITCSS

2. Rems for Font Sizes

3. Unitless Line Heights

4. Fluid typography / modular scale

5. Naming things using t-shirt

Dependents (4)

Package Sidebar

Install

npm i @bolt/settings-font-size

Weekly Downloads

10

Version

0.9.0

License

MIT

Last publish

Collaborators

  • colbycook
  • dmorse
  • mikemai2awesome
  • evanlovely
  • remydenton