Navigation

v0.0.4
Typography

Heading

A title in the ink of the page, with the line over it and the paragraph under it.

On this page

A heading is a title set in the ink of the page. Its weight is a light medium at every size: size and ink carry the hierarchy, not boldness. Its lines are balanced, so a title never leaves one word alone on its last line, and its tracking tightens as it grows. Use .heading on any heading element; the class sets the look, the element sets the level.

Heading

<header class="flex flex-col gap-sm max-w(520)">  <p class="eyebrow">Changelog</p>  <h1 class="heading heading-2xl">Faster cold builds, and comments on previews</h1>  <p class="lead">Dependency caches are restored before the install step, and anyone can leave a note on a preview, pinned to the element they clicked.</p></header>

Two companions come with it. An eyebrow is the few words over a heading that say what kind of thing follows. A lead is the paragraph under it, a step larger than body text.

#Sizes

Seven sizes, named like the rest of the scale. Pick the size by the heading's place on the page, and the element by its place in the outline: an <h2> can be heading-sm in a card and heading-2xl at the top of a section.

Sizes

<div class="flex flex-col gap-md w-full">  <p class="heading heading-display">Display</p>  <p class="heading heading-2xl">Two extra large</p>  <p class="heading heading-xl">Extra large</p>  <p class="heading heading-lg">Large</p>  <p class="heading">Medium, the default</p>  <p class="heading heading-sm">Small</p>  <p class="heading heading-xs">Extra small</p></div>
ClassSizeUse
heading-display2.5 to 4.25remThe one title of a landing page
heading-2xl2 to 2.5remA page's title, a section of a landing page
heading-xl1.625 to 2remA page's title in an application
heading-lg1.5remA section
heading1.25remA subsection, a dialog-sized panel
heading-sm1.0625remA card, a bar
heading-xs0.9375remA group of links, a dense panel

#Sizes that follow the room

The three largest sizes are written in container units. They measure the nearest size container, and where there is none, the viewport. A display heading is 2.5rem in a phone's column and 4.25rem in a wide one, with every width between; no breakpoint is involved.

Sizes that follow the room

<section class="container-inline p-xl bg-surface-base">  <h1 class="heading heading-display">Every push gets an address.</h1>  <p class="lead mt-md max-w(480)">Choose Tablet, then Phone: the title is set smaller as its container narrows, and its lines are balanced again at each size.</p></section>

To make a heading follow a panel instead of the page, make the panel a size container: container-inline on it.

#Balance

A heading wraps with text-wrap: balance: the browser evens out the lines instead of filling each one, so a title of two lines is two lines of similar length. A lead wraps with text-wrap: pretty, which avoids a last line of one word. Where a browser supports neither, the text wraps as usual.

Give a heading a measure, such as max-w(560), when it sits in a wide column. Balance evens the lines; it does not decide how many there are.

#Eyebrow and lead

Eyebrow and lead

<div class="flex flex-col gap-lg max-w(520)">  <div class="flex flex-col gap-xs">    <p class="eyebrow">Pricing</p>    <h2 class="heading heading-xl">Free to start. Fair when you grow.</h2>  </div>  <p class="lead lead-sm">A small lead, for a card or a narrow column.</p>  <p class="lead">The default lead, under a page's title.</p>  <p class="lead lead-lg">A large lead, under a display heading.</p></div>

#Accessibility

  • The class does not make a heading. Use <h1> to <h6> in order, without skipping a level, and style each with the size its place calls for.
  • A page has one <h1>.
  • An eyebrow is a <p>. It is read before the heading, which is right, but it must not be a heading itself: a list of headings should start with the title.
  • A heading is in strong ink on every surface. On an inverse sheet, add fg-text-inverse.

#Classes

ClassDescription
headingA title at 1.25rem: strong ink, a light medium weight, balanced lines
heading-xs0.9375rem, for a group of links or a dense panel. With heading
heading-sm1.0625rem, for a card or a bar. With heading
heading-lg1.5rem, for a section. With heading
heading-xl1.625 to 2rem by the width of its container, for a page's title in an application. With heading
heading-2xl2 to 2.5rem by the width of its container, for a page's title or a section of a landing page. With heading
heading-display2.5 to 4.25rem by the width of its container, for the one title of a landing page. With heading
eyebrowA small uppercase line over a heading that says what kind of thing follows; a p, not a heading
leadThe paragraph under a heading, at 1.125rem, wrapped without a last line of one word
lead-sm1rem, for a card or a narrow column. With lead
lead-lg1.25rem, under a display heading. With lead

#Custom properties

PropertyDefaultDescription
--heading-size1.25remFont size
--heading-leading1.3Line height
--heading-tracking-.012emLetter spacing

#Source

@master/ui/components/heading.css
/* * Heading: a title, the short line over it and the paragraph under it. * A heading is set in the ink of the page at a light medium weight: size and ink carry the hierarchy, not * boldness. Its lines are balanced, so a title never leaves one word alone on the last line, and its tracking * tightens as it grows. The three largest sizes follow the room they are given: they are sized in container * units, which measure the nearest size container and, where there is none, the viewport. */@layer components {  .heading {    --heading-size: 1.25rem;    --heading-leading: 1.3;    --heading-tracking: -.012em;    margin: 0;    color: var(--color-text-strong);    font: var(--font-weight-control) var(--heading-size)/var(--heading-leading) var(--font-family-sans);    font-feature-settings: inherit;    letter-spacing: var(--heading-tracking);    text-wrap: balance;    overflow-wrap: anywhere;    &.heading-xs {      --heading-size: .9375rem;      --heading-leading: 1.4;      --heading-tracking: -.004em;    }    &.heading-sm {      --heading-size: 1.0625rem;      --heading-leading: 1.35;      --heading-tracking: -.008em;    }    &.heading-lg {      --heading-size: 1.5rem;      --heading-leading: 1.25;      --heading-tracking: -.018em;    }    &.heading-xl {      --heading-size: clamp(1.625rem, 1.3rem + 1.6cqi, 2rem);      --heading-leading: 1.18;      --heading-tracking: -.024em;    }    &.heading-2xl {      --heading-size: clamp(2rem, 1.4rem + 2.6cqi, 2.5rem);      --heading-leading: 1.12;      --heading-tracking: -.03em;    }    /* Display: the one title of a page, from 2.5rem in a phone's column to 4.25rem in a wide one. */    &.heading-display {      --heading-size: clamp(2.5rem, 1.5rem + 4.4cqi, 4.25rem);      --heading-leading: 1.04;      --heading-tracking: -.038em;    }  }  /* Eyebrow: the few words over a heading that say what kind of thing follows. */  .eyebrow {    margin: 0;    color: var(--color-text-muted);    font: var(--font-weight-control) .75rem/1.4 var(--font-family-sans);    font-feature-settings: inherit;    letter-spacing: .06em;    text-transform: uppercase;  }  /* Lead: the paragraph under a heading, a step larger than body text and wrapped without orphans. */  .lead {    margin: 0;    color: var(--color-text-body);    font-size: 1.125rem;    line-height: 1.6;    text-wrap: pretty;    &.lead-sm {      font-size: 1rem;    }    &.lead-lg {      font-size: 1.25rem;      line-height: 1.5;      letter-spacing: -.006em;    }  }}