ナビゲーション

v2.1.0
タイポグラフィ

見出し

ページの前景色で表示する見出しと、その上のラベル、下の導入文。

このページの内容

見出しにはページの前景色を使います。ウェイトは階層によらず、どのサイズでもやや細めのミディアムに揃えます。階層は文字サイズと前景色で表します。行の長さを均等に調整して最終行に単語が一つだけ残るのを防ぎ、文字が大きいほど字間を詰めます。任意の見出し要素に.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>
<header className="flex flex-col gap-sm max-w(520)">  <p className="eyebrow">Changelog</p>  <h1 className="heading heading-2xl">Faster cold builds, and comments on previews</h1>  <p className="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>
<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>
<template>  <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></template>

見出しには2つの補助要素を組み合わせられます。eyebrowは見出しの上に置き、続く内容の種類を示す短いラベルです。leadは見出しの下に置く導入文で、本文より一段階大きく表示します。

#サイズ

サイズは7種類で、ほかのサイズスケールと同じ命名規則に従います。表示サイズはページ内での役割に合わせ、要素は文書構造上の位置に合わせて選びます。同じ<h2>でも、カード内ではheading-sm、セクションの先頭ではheading-2xlを使えます。

サイズ

<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>
<div className="flex flex-col gap-md w-full">  <p className="heading heading-display">Display</p>  <p className="heading heading-2xl">Two extra large</p>  <p className="heading heading-xl">Extra large</p>  <p className="heading heading-lg">Large</p>  <p className="heading">Medium, the default</p>  <p className="heading heading-sm">Small</p>  <p className="heading heading-xs">Extra small</p></div>
<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>
<template>  <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></template>
クラスサイズ用途
heading-display2.5〜4.25remランディングページのメインタイトル
heading-2xl2〜2.5remページタイトル、ランディングページのセクション
heading-xl1.625〜2remアプリケーション内のページタイトル
heading-lg1.5remセクション
heading1.25remサブセクション、ダイアログ程度の大きさのパネル
heading-sm1.0625remカード、バー
heading-xs0.9375remリンクグループ、情報量の多いパネル

#表示領域に応じたサイズ

大きい方から3つのサイズにはコンテナー単位を使います。最も近いサイズコンテナーを基準とし、該当するコンテナーがなければビューポートを基準とします。ディスプレイ見出しは、スマートフォンのような狭いカラムでは2.5rem、幅の広いカラムでは4.25remになります。その間では幅に応じて連続的に変化するため、ブレークポイントは不要です。

表示領域に応じたサイズ

<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>
<section className="container-inline p-xl bg-surface-base">  <h1 className="heading heading-display">Every push gets an address.</h1>  <p className="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>
<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>
<template>  <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></template>

パネルの幅に合わせて見出しを拡大・縮小するには、パネルにcontainer-inlineを指定してサイズコンテナーにします。

#行のバランス

見出しはtext-wrap: balanceで折り返します。ブラウザーは各行を幅いっぱいに埋める代わりに行の長さを揃えるため、2行の見出しはどちらの行も同程度の長さになります。導入文はtext-wrap: prettyで折り返し、最終行に単語が一つだけ残るのを防ぎます。どちらにも対応していないブラウザーでは、通常どおりに折り返します。

幅の広いカラムに見出しを置く場合は、max-w(560)などで行幅を指定します。行のバランス調整は、決まった行数の中で各行の長さを揃える機能です。

#見出しラベルと導入文

見出しラベルと導入文

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

#アクセシビリティ

  • クラスを付けるだけでは見出しになりません。<h1>から<h6>まで、レベルを飛ばさずに使い、表示サイズはそれぞれの役割に合わせて選びます。
  • 1ページにつき<h1>は1つです。
  • 見出しラベルには<p>を使います。読み上げ順では見出しの前に置きますが、見出し一覧がタイトルから始まるように、ラベル自体には見出し要素を使いません。
  • どの背景面でも、見出しにはコントラストの高い前景色を使います。配色を反転したシートではfg-text-inverseを追加します。

#クラス

クラス説明
heading1.25rem のタイトルです。濃い文字色とやや軽めのミディアムウェイトを使い、各行の長さがそろうように折り返します。
heading-xs0.9375rem です。リンクのグループや情報量の多いパネルに適しています。heading と併用します
heading-sm1.0625rem です。カードやバーに適しています。heading と併用します
heading-lg1.5rem です。セクションに適しています。heading と併用します
heading-xlコンテナー幅に応じて 1.625〜2rem になります。アプリケーション内のページタイトルに適しています。heading と併用します
heading-2xlコンテナー幅に応じて 2〜2.5rem になります。ページタイトルやランディングページのセクション見出しに適しています。heading と併用します
heading-displayコンテナー幅に応じて 2.5〜4.25rem になります。ランディングページに一つだけ置くタイトルに適しています。heading と併用します
eyebrow見出しの上に小さな大文字で 1 行表示し、後に続く内容の種類を示します。要素には p を使います。
lead見出しの下に置く1.125remの段落。最終行に1語だけ残らないように折り返します。
lead-sm1rem です。カードや幅の狭いカラムに適しています。lead と併用します
lead-lg1.25rem です。ディスプレイ見出しの下に配置します。lead と併用します

#カスタムプロパティ

プロパティ既定値説明
--heading-size1.25remフォントサイズ
--heading-leading1.3行の高さ
--heading-tracking-.012em字間

#ソース

@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 Latin * tracking tightens as it grows; Chinese, Japanese and Korean keep their own spacing. 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.ui {  .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;    }    /*     * Han, kana and Hangul keep their own spacing at every size: tracking that tightens Latin as it grows would     * crowd square glyphs. It follows the content's language, so a CJK title in an English page is spaced too.     */    &:is(:lang(zh), :lang(ja), :lang(ko)) {      --heading-tracking: 0em;    }  }  /* 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;    /* A long word in capitals, spaced out, breaks rather than run out of a narrow card. */    overflow-wrap: break-word;    /* The spacing is for Latin capitals; scripts without case are set as they are. */    &:is(:lang(zh), :lang(ja), :lang(ko)) {      letter-spacing: 0;    }  }  /* 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;    /* A long address or name breaks rather than run out of the column. */    overflow-wrap: break-word;    &.lead-sm {      font-size: 1rem;    }    &.lead-lg {      font-size: 1.25rem;      line-height: 1.5;      letter-spacing: -.006em;      &:is(:lang(zh), :lang(ja), :lang(ko)) {        letter-spacing: 0;      }    }  }}