Jump to main content

Typography


All text in Vanilla uses the Ubuntu typeface , which can be used in your projects.

Vanilla's typographic scale has a base font-size of 1rem.

The value of 1rem

The pixel value of 1rem depends on the browser (in most cases, 16px) and the user's browser settings.

In addition to that, Vanilla multiplies that value by $font-size-ratio--largescreen on resolutions above a certain threshold ($font-size-largescreen). This is done to account for the bigger distance at which larger screens are usually positioned from the viewer.

To disable this behaviour, include the following after you import and include the framework in your scss:

$increase-font-size-on-larger-screens: false;

Text elements in vanilla adhere to a type scale:

  • The base of the scale is the paragraph font-size (1rem)
  • The ratio of the scale is 1.14285714286 (16/14, so both 14 and 16 are members of the scale)

Heading sizes are obtained by taking the ratio to a specified power listed in the table below.

Typographic scale

Small-Medium Large

power 6 8
font size 2.22819rem 2.91029rem
line height 3rem 3.5rem

power 4.5 6
font size 1.83274rem 2.22819rem
line height 2.5rem 3rem

power 3 4
font size 1.49271rem 1.70596rem
line height 2rem 2.5rem

power 1.5 2
font size 1.22176rem 1.30612rem
line height 1.5rem 2rem
power 1 1
font size 1rem 1rem
line height 1.5rem 1.5rem
power 1 1
font size 1rem 1rem
line height 1.5rem 1.5rem

power 1 1
font size 1rem 1rem
line height 1.5rem 1.5rem

Heading classes

Heading classes can be added to text elements to give them the same visual appearance as the base h1-h6 heading elements without sacrificing correct heading order and semantics.

In the following example, each heading is actually a <p> element that has been modified to look like a particular heading size.

Sub-headings

Sub-headings visually convey importance beneath a heading, or a line of text that expands on the meaning of the heading immediately before it.

Mixed heading classes

It is also possible to apply heading classes directly to heading elements if that better suits your document style and tree.

Line length

Line length, measured in number of characters per line (CPL), has been shown to affect reading speed and comprehension. While there is little consensus on what the optimal CPL value is, most studies test with values between 45 and 95 characters per line. Wikipedia has a good historical overview and a list of studies on the subject.

The max-width of text elements in Vanilla Framework is limited using the $text-max-width variable, currently set to 40em, or around 90 characters.

Vanilla also includes a utility to unset the max-width where necessary – u-no-max-width:

Overriding or unsetting the max-width is reasonable in certain cases:

  • to avoid an orphan in some fixed, high-profile text, like a promotional banner or notification.
  • when content is wrapped in a text element unintentionally, and fixing the markup is not possible. For example, a CMS or a documentation service might insert <p> after every line break, resulting in <div>'s or <iframe>'s wrapped in <p>'s.

Ordered list

Use an ordered list when the order of the items is important.

Unordered list

Use an unordered list when the order of the items isn't important.

Definition list

Use a definition list when you want to list a group of one or more terms and descriptions.

Blockquotes and citations

Small text

Small caps text

Small caps text is used to style column headers in tables. This styling has proved useful in other contexts. To apply it, add the class p-text--small-caps.

Deprecated

Previously this style was implemented as .p-text--x-small-capitalised class name. This name is now deprecated and will be removed in next major version of Vanilla, please use .p-text--small-caps instead.

Baseline alignment: small, extra small and paragraph text

Because of the difference in line heights, small, extra small and paragraph text do not share the same baseline. In some cases, for example when used on the same line, it can be useful to align them. Use the u-align-text--small-to-default u-align-text--x-small-to-default classes to achieve baseline alignment.

Deprecated

Small caps style used to be implemented as extra small text variant with .p-text--x-small-capitalised class name that required the .u-align-text--x-small-to-default utility to align the baseline. This is not the case any more, so usage of this utility with new .p-text--small-caps (and its deprecated equivalent .p-text--x-small-capitaised) is deprecated and can be removed.

Strong text

Superscripted text

Subscripted text

Abbreviation

Font weights

If you are using the variable Ubuntu font, it comes in six weights; thin, light, regular, medium, bold and extra bold.

Muted text

To reduce the prominence of text, use class u-text--muted.

Enabling Cyrillic, Greek and Latin fonts

Due to the extra weight of loading these fonts they are not imported by default. To enable Cyrillic, Greek and Latin fonts on Ubuntu please set the following font setting to true.

$font-allow-cyrillic-greek-latin: true;

Deprecated

In previous versions of Vanilla (< 3.10.0) there used to be an option $font-use-subset-latin for only importing a part of the Latin subset.

This has been made redundant by the adoption of the variable font and should be removed from your project.

font-display options

The CSS font-display option allows you to set a strategy for what backup font is shown while an external font is loading. This is a very subjective decision; however, if you set the following variable to the option you want, it will add it to the typography for you.

$font-display-option: <auto | block | swap | fallback | optional>;

The default value of the font-display property on all fonts used by Vanilla is set to fallback.

Import

To import just this base element into your project, copy the snippet below and include it in your main Sass file.

@import 'patterns_headings';

For more information see Customising Vanilla in your projects, which includes overrides and importing instructions.

For more typographic related information view the code and pull quote pattern component or our font settings.