ナビゲーション

v2.1.0
ナビゲーション

ページャー

記事の末尾に置く、前後のページへのリンク。

このページの内容

ページャーは記事の末尾で、前後のページへのリンクを横に並べます。各リンクは平らな面で、リンク先のタイトルの上に控えめなラベルが付きます。前後の区別には rel="prev" と rel="next" を使います。スタイルシートはその値を参照するため、方向を指定するクラスは不要です。

ページャー

<nav class="pager max-w(560) mx-auto" aria-label="Guide pages">  <a class="pager-link" rel="prev" href="#installation">    <span class="pager-label">      <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M13.6362 7.5189A0.4947 0.4947 0 0 0 13.5 7.5L2.4755 7.5006A0.5 0.5 0 0 0 2.4266 8.4946L2.5 8.5H13.5A0.4947 0.4947 0 0 0 13.6362 8.4811A0.7009 0.7009 0 0 0 13.6362 7.5189Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(180 8 8)" /><path d="M8 4.5L13.2348 7.8313A0.2 0.2 0 0 1 13.2348 8.1687L8 11.5" transform="rotate(180 8 8)" />      </svg>Previous    </span>    <span class="pager-title">Installation</span>  </a>  <a class="pager-link" rel="next" href="#theming">    <span class="pager-label">      Next<svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M13.6362 7.5189A0.4947 0.4947 0 0 0 13.5 7.5L2.4755 7.5006A0.5 0.5 0 0 0 2.4266 8.4946L2.5 8.5H13.5A0.4947 0.4947 0 0 0 13.6362 8.4811A0.7009 0.7009 0 0 0 13.6362 7.5189Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><path d="M8 4.5L13.2348 7.8313A0.2 0.2 0 0 1 13.2348 8.1687L8 11.5" />      </svg>    </span>    <span class="pager-title">Theming</span>  </a></nav>
import ArrowLeftIcon from '@master/icons-react/native/16/soft/arrow-left'import ArrowRightIcon from '@master/icons-react/native/16/soft/arrow-right'<nav className="pager max-w(560) mx-auto" aria-label="Guide pages">  <a className="pager-link" rel="prev" href="#installation">    <span className="pager-label"><ArrowLeftIcon className="icon" />Previous</span>    <span className="pager-title">Installation</span>  </a>  <a className="pager-link" rel="next" href="#theming">    <span className="pager-label">Next<ArrowRightIcon className="icon" /></span>    <span className="pager-title">Theming</span>  </a></nav>
<script>  import ArrowLeftIcon from '@master/icons-svelte/native/16/soft/arrow-left'  import ArrowRightIcon from '@master/icons-svelte/native/16/soft/arrow-right'</script><nav class="pager max-w(560) mx-auto" aria-label="Guide pages">  <a class="pager-link" rel="prev" href="#installation">    <span class="pager-label"><ArrowLeftIcon class="icon" />Previous</span>    <span class="pager-title">Installation</span>  </a>  <a class="pager-link" rel="next" href="#theming">    <span class="pager-label">Next<ArrowRightIcon class="icon" /></span>    <span class="pager-title">Theming</span>  </a></nav>
<script setup>import ArrowLeftIcon from '@master/icons-vue/native/16/soft/arrow-left'import ArrowRightIcon from '@master/icons-vue/native/16/soft/arrow-right'</script><template>  <nav class="pager max-w(560) mx-auto" aria-label="Guide pages">    <a class="pager-link" rel="prev" href="#installation">      <span class="pager-label"><ArrowLeftIcon class="icon" />Previous</span>      <span class="pager-title">Installation</span>    </a>    <a class="pager-link" rel="next" href="#theming">      <span class="pager-label">Next<ArrowRightIcon class="icon" /></span>      <span class="pager-title">Theming</span>    </a>  </nav></template>

#属性でリンクの配置を決める

rel は、現在のページとリンク先の関係を示す HTML 属性です。prev と next はその値の一部です。ページャーの各リンクには、いずれかの値を指定します。どちらも、順序のあるページ同士の前後関係を示す適切なマークアップです。スタイルシートはその値を参照し、表示を次の 3 点で調整します。

  • 次のページへのリンクは行の末尾に置き、テキストも末尾揃えにします。
  • ポインターを重ねると、矢印は指している方向へ動きます。次のページでは前へ、前のページでは後ろへ動きます。右から左に読むページでは、両方の矢印の向きが反転します。
  • 次のページへのリンクしかない場合も、見つけやすくタップしやすいように、行の末尾に配置します。

矢印はラベルに置くアイコンです。16px の Master Icons の図案を、ラベルが 14px で表示します。前のページでは語の前に arrow-left を、次のページでは語の後ろに arrow-right を置きます。

リンク先が存在しない場合は、そのリンクを省いてください。ガイドの最初のページには「次へ」だけ、最後のページには「前へ」だけを置きます。

最初のページ

<nav class="pager max-w(560) mx-auto" aria-label="Guide pages">  <a class="pager-link" rel="next" href="#installation">    <span class="pager-label">      Next<svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M13.6362 7.5189A0.4947 0.4947 0 0 0 13.5 7.5L2.4755 7.5006A0.5 0.5 0 0 0 2.4266 8.4946L2.5 8.5H13.5A0.4947 0.4947 0 0 0 13.6362 8.4811A0.7009 0.7009 0 0 0 13.6362 7.5189Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><path d="M8 4.5L13.2348 7.8313A0.2 0.2 0 0 1 13.2348 8.1687L8 11.5" />      </svg>    </span>    <span class="pager-title">Installation</span>  </a></nav>
import ArrowRightIcon from '@master/icons-react/native/16/soft/arrow-right'<nav className="pager max-w(560) mx-auto" aria-label="Guide pages">  <a className="pager-link" rel="next" href="#installation">    <span className="pager-label">Next<ArrowRightIcon className="icon" /></span>    <span className="pager-title">Installation</span>  </a></nav>
<script>  import ArrowRightIcon from '@master/icons-svelte/native/16/soft/arrow-right'</script><nav class="pager max-w(560) mx-auto" aria-label="Guide pages">  <a class="pager-link" rel="next" href="#installation">    <span class="pager-label">Next<ArrowRightIcon class="icon" /></span>    <span class="pager-title">Installation</span>  </a></nav>
<script setup>import ArrowRightIcon from '@master/icons-vue/native/16/soft/arrow-right'</script><template>  <nav class="pager max-w(560) mx-auto" aria-label="Guide pages">    <a class="pager-link" rel="next" href="#installation">      <span class="pager-label">Next<ArrowRightIcon class="icon" /></span>      <span class="pager-title">Installation</span>    </a>  </nav></template>

#質感と動き

リンクは 1 本の輪郭で囲んだ平らな面で、角の丸みは大きなコントロールに揃えます。ポインターを重ねると面が一段浮き、矢印は指している方向へ 2px 動きます。押すと面がくぼみます。動きを抑える設定では、矢印は移動しません。

ページャーはサイズコンテナーです。自身の幅が 26rem 未満になると、前のページ、次のページの順に縦に並び、各リンクがページャーの幅いっぱいに広がります。

#ページャーとページネーション

ページャーは順に読むページをタイトル付きで案内します。ページネーションは、長い一覧を分割した番号付きページ間の移動に使います。サイト内での現在位置を示すには、パンくずリストを使います。

#アクセシビリティ

  • リンクは aria-label を指定した <nav> に入れてください。ページ内に複数のナビゲーションがあっても、このランドマークの用途を識別できます。
  • リンクの名前は、「次へ、テーマ設定」のようにラベルとタイトルを組み合わせたものです。タイトルだけでは移動する方向が伝わらないため、ラベルも残してください。
  • 矢印は aria-hidden="true" を付けたアイコンで、読み上げの対象にはなりません。

#クラス

クラス説明
pagerアクセシブルな名前を持つ nav 要素に適用し、2 つのリンクを横に並べます。コンテナーの幅が 26rem 未満になると縦に並びます。
pager-linkrel="prev" または rel="next" を付けたリンクです。通常は平らな面で、ポインターを重ねると一段浮き上がります。次のページへのリンクは末尾に配置し、テキストも末尾に揃えます。
pager-labelタイトルの上に控えめに表示する「前へ」または「次へ」。リンク先の方向を指すアイコンを添えます。前のページでは語の前に、次のページでは語の後ろに矢印を置きます。ラベルがアイコンを 14px にし、右から左に読むページでは向きを反転します。
pager-titleリンク先ページのタイトル

#ソース

@master/ui/components/pager.css
/* * Pager: the page before and the page after, at the foot of an article. * Two links side by side, each a flat face with a quiet word over the title of the page it leads to. The * links say which is which with rel="prev" and rel="next", and the stylesheet reads that: the next page * stands at the end with its words set to the end, and an arrow points the way each one goes. The arrow is an * icon in the markup, beside the word: the stylesheet sizes it, moves it and turns it in a right-to-left page. * A pager with only a next page keeps it at the end. * Under the pointer a link rises a step and its arrow moves 2px the way it points. In a narrow container the * two stack. * Geometry: a large control's corner, 14px by 16px of padding, 12px between the two. */@layer components.ui {  .pager {    container-type: inline-size;    display: grid;    grid-template-columns: repeat(2, minmax(0, 1fr));    gap: .75rem;    min-width: 0;    margin: 0;    padding: 0;    list-style: none;    @container (width < 26rem) {      .pager-link, .pager-link[rel~="next"] {        grid-column: 1 / -1;      }    }  }  .pager-link {    --pager-travel: 0px;    display: grid;    gap: .125rem;    min-width: 0;    padding: .875rem 1rem;    border-radius: calc(var(--radius-control-lg) * var(--corner-scale));    corner-shape: var(--corner-shape);    background: var(--color-surface-raised);    color: var(--color-text-body);    box-shadow: var(--shadow-flat);    text-decoration: none;    touch-action: manipulation;    -webkit-tap-highlight-color: transparent;    transition: box-shadow var(--duration-quick) var(--easing-glide);    /* The page after: at the end, with its words set to the end. */    &[rel~="next"] {      grid-column: 2;      justify-items: end;      text-align: end;    }    @media (hover: hover) {      &:hover {        --pager-travel: 2px;        box-shadow: var(--shadow-raised);      }    }    &:active {      background: var(--color-surface-inset);      box-shadow: var(--shadow-pressed);      transition-duration: var(--duration-press);    }    &:focus-visible {      @apply --focus-ring;    }    @media (prefers-reduced-motion: reduce) {      --pager-travel: 0px;      @media (hover: hover) {        &:hover {          --pager-travel: 0px;        }      }    }    @media (forced-colors: active) {      outline: 1px solid LinkText;      outline-offset: -1px;    }  }  /*   * The quiet word: Previous, Next. The icon beside it is its arrow, 14px, which the label holds before the word   * of the page before and after the word of the next.   */  .pager-label {    --icon-size: .875rem;    display: inline-flex;    align-items: center;    gap: .25rem;    margin: 0;    color: var(--color-text-muted);    font-size: .78125rem;    line-height: 1.25rem;    .icon {      transition: translate var(--duration-quick) var(--easing-glide);    }  }  /* Under the pointer an arrow moves the way it points: back for the page before, on for the next. */  .pager-link:not([rel~="next"]) .pager-label .icon {    translate: calc(-1 * var(--pager-travel)) 0;  }  .pager-link[rel~="next"] .pager-label .icon {    translate: var(--pager-travel) 0;  }  /* In a right-to-left page the same two drawings are turned round, and so is the way each moves. */  .pager-link:not([rel~="next"]) .pager-label:dir(rtl) .icon {    scale: -1 1;    translate: var(--pager-travel) 0;  }  .pager-link[rel~="next"] .pager-label:dir(rtl) .icon {    scale: -1 1;    translate: calc(-1 * var(--pager-travel)) 0;  }  /* The title of the page it leads to. */  .pager-title {    min-width: 0;    margin: 0;    color: var(--color-text-strong);    font-weight: var(--font-weight-control);    font-size: .9375rem;    line-height: 1.35;    text-wrap: balance;    overflow-wrap: anywhere;  }}