ナビゲーション

v2.1.0
質感

重ね表示

複数の項目を重ね、下の縁をのぞかせる表示。

このページの内容

重ね表示は、同じ種類の通知、まとめて送られたファイル、同じ文書の下書きなど、複数の項目をひとまとまりに表示します。最上面となる要素を 1 つ置き、その背後に 2 枚の面を描画します。下の面ほど幅が狭く、位置が低く、色が淡くなります。下の 2 枚は、影ではなく最上面の下に重なったシートに見えます。

重ね表示

<div class="pile w-full max-w(340)">  <article class="card">    <header class="card-header">      <h3 class="card-title">3 deployments failed</h3>      <p class="card-description">atlas.dev, in the last hour</p>      <button class="card-action btn btn-sm" type="button">Show all</button>    </header>  </article></div>
<div className="pile w-full max-w(340)">  <article className="card">    <header className="card-header">      <h3 className="card-title">3 deployments failed</h3>      <p className="card-description">atlas.dev, in the last hour</p>      <button className="card-action btn btn-sm" type="button">Show all</button>    </header>  </article></div>
<div class="pile w-full max-w(340)">  <article class="card">    <header class="card-header">      <h3 class="card-title">3 deployments failed</h3>      <p class="card-description">atlas.dev, in the last hour</p>      <button class="card-action btn btn-sm" type="button">Show all</button>    </header>  </article></div>
<template>  <div class="pile w-full max-w(340)">    <article class="card">      <header class="card-header">        <h3 class="card-title">3 deployments failed</h3>        <p class="card-description">atlas.dev, in the last hour</p>        <button class="card-action btn btn-sm" type="button">Show all</button>      </header>    </article>  </div></template>

#重なりの仕組み

重ね表示には、カード、シート、ファイルなど、面を持つ要素を 1 つ入れます。下の 2 枚はスタイルシートが描画し、それぞれ直上の面から左右を 8px ずつ内側に、位置を 6px 下にずらします。重ね表示自体が最上面の下に 12px を確保するため、後続の要素に余白を追加する必要はありません。

下のシートには、面の角の丸みを定める --pile-radius が適用されます。最上面の角の丸みが異なる場合は、下のファイルの例のように、その値をプロパティに設定してください。--pile-step と --pile-inset で各シートの見える範囲を調整できます。

ファイル

<div class="pile w-full max-w(280)" style="--pile-radius: var(--radius-control-lg)">  <div class="file">    <span class="file-page">pdf</span>    <div class="file-body">      <p class="file-name">Quarterly report.pdf</p>      <p class="file-meta">and 4 more files · 12.8 MB</p>    </div>  </div></div>
<div className="pile w-full max-w(280)" style={{ '--pile-radius': 'var(--radius-control-lg)' } as React.CSSProperties}>  <div className="file">    <span className="file-page">pdf</span>    <div className="file-body">      <p className="file-name">Quarterly report.pdf</p>      <p className="file-meta">and 4 more files · 12.8 MB</p>    </div>  </div></div>
<div class="pile w-full max-w(280)" style="--pile-radius: var(--radius-control-lg)">  <div class="file">    <span class="file-page">pdf</span>    <div class="file-body">      <p class="file-name">Quarterly report.pdf</p>      <p class="file-meta">and 4 more files · 12.8 MB</p>    </div>  </div></div>
<template>  <div class="pile w-full max-w(280)" style="--pile-radius: var(--radius-control-lg)">    <div class="file">      <span class="file-page">pdf</span>      <div class="file-body">        <p class="file-name">Quarterly report.pdf</p>        <p class="file-meta">and 4 more files · 12.8 MB</p>      </div>    </div>  </div></template>

#項目数の表示

下に重ねるシートは装飾です。項目が 3 件でも 30 件でもシートは常に 2 枚で、読み上げの対象にはなりません。最上面に件数をテキストで示し、グループを開くボタンや一覧へのリンクなど、すべての項目を確認できる手段を用意してください。

#重ね表示、リスト、アバターグループ

重ね表示は、すべての項目を見せる必要がない場合に使います。一つひとつの項目を見せることが重要な場合は、リストを使ってください。人物をまとめて表示するには、アバターを重ねるアバターグループを使います。スライドを順に切り替えるには、カルーセルを使います。

#アクセシビリティ

  • 重ね表示自体にはロールもアクセシブルな名前も追加されません。意味は最上面の要素で伝えます。
  • 重なりの見た目からは件数がわからないため、テキストで明記してください。
  • 強制カラーモードでは、下の 2 枚のシートにはシステム色の輪郭が付き、完全に不透明になります。

#クラス

クラス説明
pile最前面のサーフェスを保持する要素。背後に 2 枚のシートを重ね、各シートを一つ上のシートより左右それぞれ 8px 内側、下に 6px ずらします。

#カスタムプロパティ

プロパティ既定値説明
--pile-radiusvar(--radius-surface)最前面の下に重なるシートの角丸。最前面のサーフェスと同じ値に設定します。
--pile-step.375rem各シートが一つ上のシートの下端から見える高さ
--pile-inset.5rem各シートが一つ上のシートより左右それぞれ内側に入る距離

#ソース

@master/ui/components/pile.css
/* * Pile: several things shown as one, with the edges of the others under it. * The pile holds one surface, the top one, and draws two more behind it: each a step narrower, a step lower * and a step fainter, so they read as sheets lying under the first and not as a shadow. Nothing in them is * content: say how many there are in words, on the top one. * Geometry: each sheet under the top is 8px in on both sides and shows 6px below the one above it. They take * the corner in --pile-radius, a surface's corner unless the top sheet has another. */@layer components.ui {  .pile {    --pile-radius: var(--radius-surface);    --pile-step: .375rem;    --pile-inset: .5rem;    position: relative;    /* The sheets lie behind the top one, and no further back than the pile. */    isolation: isolate;    display: grid;    min-width: 0;    margin: 0;    padding-block-end: calc(var(--pile-step) * 2);    &::before, &::after {      content: '';      position: absolute;      inset-block-start: 1rem;      border-radius: calc(var(--pile-radius) * var(--corner-scale));      corner-shape: var(--corner-shape);      background: var(--color-surface-raised-low);      box-shadow: var(--shadow-flat), 0 1px 2px -1px var(--color-shade-2);      pointer-events: none;    }    /* The second sheet. */    &::before {      z-index: -1;      inset-block-end: var(--pile-step);      inset-inline: var(--pile-inset);      opacity: .8;    }    /* The third. */    &::after {      z-index: -2;      inset-block-end: 0;      inset-inline: calc(var(--pile-inset) * 2);      opacity: .5;    }    @media (forced-colors: active) {      &::before, &::after {        outline: 1px solid CanvasText;        outline-offset: -1px;        opacity: 1;      }    }  }}