ナビゲーション

v2.1.0
サイト内のページ

検索結果

検索フィールド、その横の絞り込み条件、カードまたはリストで表示する結果を、ページ送り付きで構成します。

検索結果ページは、検索に答えるページです。語句を入力するフィールド、見つかったものを絞り込む条件、件数、並べ替え、ページに分けた結果で構成します。ヘッダー、メイン領域、フッターからなるページのフレームを土台とし、ドキュメント全体がスクロールします。絞り込み条件は、余裕があるときは結果の横に並び、ないときはドロワーに収まります。

検索結果

<div class="page bg-surface-base fg-text-body text-sm" data-example="results">  <a class="skip" href="#rs-main">Skip to content</a>  <header class="navbar" style="--navbar-padding-x: max(1.5rem, calc(50% - 33.5rem))">    <a class="navbar-brand" href="#">      <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <circle cx="8" cy="8" r="6" />        <path d="M8 4.3333A3.6667 3.6667 0 0 1 8 11.6667Z" fill="currentColor" stroke="none" />      </svg>Atlas</a>    <nav class="navbar-nav" aria-label="Main">      <a class="navbar-link" href="#">Product</a>      <a class="navbar-link" href="#">Pricing</a>      <a class="navbar-link" href="#">Docs</a>      <a class="navbar-link" href="#" aria-current="page">Resources</a>    </nav>    <div class="navbar-end">      <a class="btn btn-sm hidden inline-flex@container(--xl)" href="#">Sign in</a>      <button type="button" class="btn btn-quiet btn-square btn-sm navbar-toggle" popovertarget="rs-menu" aria-label="Open the menu">        <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="M3 5.5L13 5.5" />          <path d="M3 10.5L13 10.5" />        </svg>      </button>      <div class="menu menu-end" id="rs-menu" popover>        <a class="menu-item" href="#">Product</a>        <a class="menu-item" href="#">Pricing</a>        <a class="menu-item" href="#">Docs</a>        <a class="menu-item" href="#" aria-current="page">Resources</a>        <a class="menu-item" href="#">Sign in</a>      </div>    </div>  </header>  <main class="grow(1) w-full max-w(1120) mx-auto px-lg py-xl container-inline" id="rs-main" tabindex="-1">    <header class="flex flex-col gap-3xs">      <h1 class="heading heading-xl">Resources</h1>      <p class="m(0) fg-text-muted">Guides, templates, videos and case studies for teams that deploy with Atlas.</p>    </header>    <form class="flex flex-wrap gap-xs max-w(560) mt-lg" id="rs-form" method="get" role="search" aria-label="Resources">      <label class="input-group grow(1) basis(200) min-w(0)">        <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">          <circle cx="7" cy="7" r="4.5" />          <path d="M10.182 10.182L14 14" />        </svg>        <input class="input-group-field" type="search" name="q" placeholder="Search resources" aria-label="Search resources" autocomplete="off">      </label>      <button class="btn">Search</button>    </form>    <div class="flex flex-col gap-lg mt-xl flex-row@container(--4xl) gap-xl@container(--4xl)">      <div class="w(240)@container(--4xl) pt(6)@container(--4xl) shrink(0)" data-results="sidebar">        <fieldset class="fieldset" data-results="conditions">          <legend class="fieldset-legend">Type</legend>          <label class="check flex">            <input type="checkbox" class="checkbox" name="type" value="guide" form="rs-form">            <span class="grow(1)">Guides</span>            <span class="fg-text-muted" data-count="guide">4</span>          </label>          <label class="check flex">            <input type="checkbox" class="checkbox" name="type" value="template" form="rs-form">            <span class="grow(1)">Templates</span>            <span class="fg-text-muted" data-count="template">3</span>          </label>          <label class="check flex">            <input type="checkbox" class="checkbox" name="type" value="video" form="rs-form">            <span class="grow(1)">Videos</span>            <span class="fg-text-muted" data-count="video">3</span>          </label>          <label class="check flex">            <input type="checkbox" class="checkbox" name="type" value="case-study" form="rs-form">            <span class="grow(1)">Case studies</span>            <span class="fg-text-muted" data-count="case-study">2</span>          </label>        </fieldset>      </div>      <section class="grow(1) basis(0) min-w(0) flex flex-col gap-md" aria-labelledby="rs-results-title">        <h2 class="sr-only" id="rs-results-title">Results</h2>        <div class="flex flex-wrap items-center gap-xs">          <div class="hidden@container(--4xl)" data-results="open" hidden>            <button type="button" class="btn btn-sm" commandfor="rs-filters" command="show-modal">              <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="M4.5365 3L11.4635 3A1 1 0 0 1 12.2548 4.6114L9.4587 8.2299A1 1 0 0 0 9.25 8.8413L9.25 11.323A1 1 0 0 1 8.6214 12.2514L7.875 12.55A0.8203 0.8203 0 0 1 6.75 11.7883L6.75 8.8413A1 1 0 0 0 6.5413 8.2299L3.7452 4.6114A1 1 0 0 1 4.5365 3Z" />              </svg>Filters              <span data-results="applied" hidden>                <span class="badge badge-sm badge-ink badge-pill" aria-hidden="true">0</span>                <span class="sr-only">, 0 applied</span>              </span>            </button>          </div>          <p class="m(0) grow(1) fg-text-muted" id="rs-count" role="status">12 resources</p>          <div data-results="clear" hidden>            <button type="button" class="btn btn-quiet btn-sm">Clear all</button>          </div>          <div class="flex flex-wrap items-center justify-between gap-xs grow(1) grow(0)@container(--md)">            <label class="flex flex-wrap items-center gap-xs fg-text-muted">Sort              <select class="select select-sm" name="sort" form="rs-form">                <option class="select-option" value="updated">Recently updated</option>                <option class="select-option" value="name">Name</option>              </select>            </label>            <div class="segmented segmented-sm" role="radiogroup" aria-label="Show results as">              <label class="segmented-item">                <input type="radio" class="segmented-input" name="view" value="cards" form="rs-form" checked>Cards</label>              <label class="segmented-item">                <input type="radio" class="segmented-input" name="view" value="list" form="rs-form">List</label>            </div>          </div>        </div>        <div id="rs-results">          <ul class="auto-grid" style="--auto-grid-min: 15rem">            <li class="card">              <header class="card-header">                <h3 class="card-title">                  <a class="card-link" href="#">Deploy your first project</a>                </h3>                <p class="card-description">Connect a repository, push to main and open the address Atlas gives it.</p>              </header>              <div class="card-body flex flex-wrap items-center justify-between gap-xs mt-auto fg-text-muted">                <span class="badge">Guide</span>                <time datetime="2026-11-12">Nov 12, 2026</time>              </div>            </li>            <li class="card">              <header class="card-header">                <h3 class="card-title">                  <a class="card-link" href="#">A tour of the new dashboard</a>                </h3>                <p class="card-description">Four minutes through projects, domains and usage, now on one page.</p>              </header>              <div class="card-body flex flex-wrap items-center justify-between gap-xs mt-auto fg-text-muted">                <span class="badge">Video</span>                <time datetime="2026-11-10">Nov 10, 2026</time>              </div>            </li>            <li class="card">              <header class="card-header">                <h3 class="card-title">                  <a class="card-link" href="#">How Borealis cut cold builds to under a minute</a>                </h3>                <p class="card-description">Restoring caches before the install step, measured across forty projects.</p>              </header>              <div class="card-body flex flex-wrap items-center justify-between gap-xs mt-auto fg-text-muted">                <span class="badge">Case study</span>                <time datetime="2026-11-06">Nov 6, 2026</time>              </div>            </li>            <li class="card">              <header class="card-header">                <h3 class="card-title">                  <a class="card-link" href="#">Astro blog starter</a>                </h3>                <p class="card-description">Posts in Markdown, a feed and a preview deployment for every draft.</p>              </header>              <div class="card-body flex flex-wrap items-center justify-between gap-xs mt-auto fg-text-muted">                <span class="badge">Template</span>                <time datetime="2026-11-03">Nov 3, 2026</time>              </div>            </li>            <li class="card">              <header class="card-header">                <h3 class="card-title">                  <a class="card-link" href="#">Roll back without a meeting</a>                </h3>                <p class="card-description">A deployment never changes, so going back is choosing an earlier one.</p>              </header>              <div class="card-body flex flex-wrap items-center justify-between gap-xs mt-auto fg-text-muted">                <span class="badge">Guide</span>                <time datetime="2026-10-29">Oct 29, 2026</time>              </div>            </li>            <li class="card">              <header class="card-header">                <h3 class="card-title">                  <a class="card-link" href="#">Reading a build log</a>                </h3>                <p class="card-description">Where a failed build says what went wrong, and what the timings mean.</p>              </header>              <div class="card-body flex flex-wrap items-center justify-between gap-xs mt-auto fg-text-muted">                <span class="badge">Video</span>                <time datetime="2026-10-24">Oct 24, 2026</time>              </div>            </li>          </ul>        </div>        <div data-results="foot">          <div class="flex flex-wrap items-center justify-between gap-sm">            <p class="m(0) fg-text-muted" id="rs-range">1–6 of 12</p>            <nav aria-label="Pagination">              <ol class="pagination" id="rs-pages">                <li>                  <a class="btn btn-quiet btn-square btn-sm" aria-label="Previous page" aria-disabled="true">                    <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="M6 3.5L10.3586 7.8586A0.2 0.2 0 0 1 10.3586 8.1414L6 12.5" transform="rotate(180 8 8)" />                    </svg>                  </a>                </li>                <li>                  <a class="btn btn-quiet btn-square btn-sm" href="?page=1" aria-label="Page 1" aria-current="page">1</a>                </li>                <li>                  <a class="btn btn-quiet btn-square btn-sm" href="?page=2" aria-label="Page 2">2</a>                </li>                <li>                  <a class="btn btn-quiet btn-square btn-sm" href="?page=2" aria-label="Next page">                    <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="M6 3.5L10.3586 7.8586A0.2 0.2 0 0 1 10.3586 8.1414L6 12.5" />                    </svg>                  </a>                </li>              </ol>            </nav>          </div>        </div>        <p class="sr-only" id="rs-status" role="status"></p>      </section>    </div>    <dialog class="dialog dialog-drawer" id="rs-filters" closedby="any" aria-labelledby="rs-filters-title" style="--dialog-width: 20rem">      <header class="dialog-header">        <h2 class="dialog-title" id="rs-filters-title">Filters</h2>      </header>      <div class="dialog-body" data-results="drawer"></div>      <footer class="dialog-footer">        <button type="button" class="btn" data-results="drawer-clear">Clear</button>        <button type="button" class="btn btn-primary" commandfor="rs-filters" command="close" data-results="drawer-done" aria-live="polite">Show 12 results</button>      </footer>      <button type="button" class="btn btn-quiet btn-square btn-sm dialog-close" commandfor="rs-filters" command="close" aria-label="Close the filters">        <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="M4 4L12 12" />          <path d="M4 12L12 4" />        </svg>      </button>    </dialog>  </main>  <footer class="bt(1) bt-solid b-line-hair">    <div class="flex flex-wrap items-center justify-between gap-sm w-full max-w(1120) mx-auto px-lg py-lg text-xs fg-text-muted">      <span>© 2026 Atlas Labs</span>      <nav class="flex flex-wrap gap-lg" aria-label="Footer">        <a class="link link-quiet" href="#">Privacy</a>        <a class="link link-quiet" href="#">Terms</a>        <a class="link link-quiet" href="#">Status</a>      </nav>    </div>  </footer>  <template id="rs-cards">    <ul class="auto-grid" style="--auto-grid-min: 15rem">      <li class="card">        <header class="card-header">          <h3 class="card-title">            <a class="card-link" href="#"></a>          </h3>          <p class="card-description"></p>        </header>        <div class="card-body flex flex-wrap items-center justify-between gap-xs mt-auto fg-text-muted">          <span class="badge"></span>          <time></time>        </div>      </li>    </ul>  </template>  <template id="rs-list">    <ul class="list list-interactive mx(-10)">      <li>        <a class="list-row" href="#">          <div class="list-body">            <h3 class="list-title"></h3>            <p class="list-description"></p>          </div>          <span class="list-end flex items-center gap-sm fg-text-muted">            <time class="hidden inline@container(--md)"></time>            <span class="badge"></span>          </span>        </a>      </li>    </ul>  </template>  <template id="rs-empty">    <div class="empty">      <span class="icon-frame empty-media" aria-hidden="true">        <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round">          <circle cx="8.75" cy="8.75" r="5.75" />          <path d="M12.8159 12.8159L17.5 17.5" />        </svg>      </span>      <h3 class="empty-title">No resources match</h3>      <p class="empty-description">Try another word or fewer types, or clear the conditions to see all 12 resources.</p>      <div class="empty-actions">        <button type="button" class="btn btn-sm" data-results="reset">Clear conditions</button>      </div>    </div>  </template>  <template id="rs-page">    <ol class="pagination">      <li>        <a class="btn btn-quiet btn-square btn-sm" aria-label="Page"></a>      </li>    </ol>  </template></div>
「build」を検索してから、検索語を消します。名前順に並べ替え、2 ページ目に移動して「List」に切り替えても、並べ替えとページはそのままです。「タブレット」または「スマートフォン」を選び、「Filters」を開いて種類にチェックを入れてから「デスクトップ」を選ぶと、サイドバーでも同じ項目にチェックが入っています。存在しない語句を検索すると、空の状態を確認できます。

12 件のリソースは例自体のファイルにある行で、例のスクリプトはそこから結果を返します。実際のページではサーバーに問い合わせます。その箇所はサーバーとの接続で説明します。

#構成

  • フレームに page、その内側の幅は 1 つ。 メイン領域は grow(1) max-w(1120) mx-auto px-lg で、フッターの中身も同じ幅です。ナビゲーションバーは全幅に広がり、その --navbar-padding-x は max(1.5rem, calc(50% - 33.5rem))、つまりコンテンツ自体の開始位置です。そのため、ブランド、タイトル、検索フィールド、フッターの最初の語が、どの幅でも同じ線に並びます。
  • 検索は独立したフォームです。 <form method="get" role="search"> に、q という名前のフィールドと送信ボタンを収めます。フィールドは input-group で、フォームの max-w(560) まで広がります。フィールドが 200px より狭くなる幅では、ボタンがフィールドの下に移ります。
  • ほかのフィールドはフォームを名前で指します。 種類のチェックボックス、並べ替え、「Cards」と「List」の切り替えは <form> の外にあり、form="rs-form" を持ちます。どこに置かれていてもフォームと一緒に送信されるため、チェックボックスをドロワーへ移せます。
  • 56rem から 2 カラム。 メイン領域はサイズコンテナー container-inline です。本体は flex flex-col で、メイン領域が 56rem 以上になると flex-row@container(--4xl) になります。絞り込み条件には w(240)(15rem)のカラム、結果には可変幅の grow(1) basis(0) min-w(0) のカラムを使います。
  • 件数、並べ替え、表示の切り替えを 1 行に。 件数は role="status" を持つ段落で、残りの幅を使うため、並べ替えと切り替えは末尾に並びます。この行は折り返します。スマートフォンでは、並べ替えと切り替えが 2 行目に移り、両端に分かれます。
  • 結果はどちらの表示でもリストです。 カード表示では、--auto-grid-min: 15rem を指定した <ul class="auto-grid"> にカードを並べます。「デスクトップ」で 3 列、「タブレット」で 2 列、「スマートフォン」で 1 列になり、列数はグリッドが数えます。リスト表示では、行がリンクである <ul class="list list-interactive"> です。mx(-10) によって、行のテキストがカラムの端にそろいます。1 ページに 6 件を表示し、その下に範囲と、リンクで構成したページネーションを置きます。
  • 何も見つからないときは空の状態です。 見つからなかったことと、次に試せることを伝え、ボタンで検索語と種類を消去します。

#絞り込み条件の配置

チェックボックスは 1 組だけです。サイドバーに書いてあり、複製するのではなく移動します。

  • メイン領域が 56rem 以上のとき 絞り込み条件は結果の横の 15rem のカラムで、「Filters」ボタンは hidden@container(--4xl) で隠れます。
  • 56rem 未満のとき カラムは空になって非表示になり、「Filters」ボタンが表示されます。ボタンは、command="show-modal" と commandfor でドロワーを開きます。ドロワーは、--dialog-width: 20rem を指定した dialog dialog-drawer です。スクリプトが <fieldset> をドロワーの本体に入れます。ボタンのバッジは、チェックの入っている種類の数を示します。
  • しきい値はスタイルシートが持ちます。 スクリプトは数値を持ちません。メイン領域の大きさが変わると、「Filters」ボタンが表示されているかを調べ、その結果に従って fieldset をサイドバーかドロワーに置きます。マークアップの --4xl を変えれば、スクリプトもそれに従います。
  • 幅が変わっても何も失われません。 何も複製していないからです。ドロワーでチェックを入れたチェックボックスは、サイドバーのチェックボックスそのものです。2 つ目の id も、コピーすべき状態もありません。ドロワーを開いたままページが広くなると、ドロワーは閉じ、フォーカスは元のチェックボックスに残ります。
  • ドロワーでは、選択がすぐに反映されます。 ドロワーの背後で結果が変わり、確定ボタンは「Show 4 results」のように件数を示して、ドロワーを閉じます。「Clear」は種類のチェックを外し、検索語はそのまま残します。

スクリプトがない場合、fieldset は書かれた場所にとどまります。56rem 未満では結果の上、それ以上では結果の横です。「Filters」ボタンは、開いても空のドロワーしか出せないため、hidden のままです。

#サーバーとの接続

マークアップは、サーバーが最初のページとして送る内容そのものです。6 件の結果、件数、ページネーションのリンクが含まれます。利用者が設定できるものはすべて、1 つの GET フォームの名前付きフィールドなので、URL がそのまま状態になります。

  • クエリー 送信すると ?q=build&type=guide&type=video&sort=name&view=list が送られます。type は、チェックの入ったボックスごとに 1 回ずつ繰り返されます。sort は updated または name、view は cards または list です。フォームには action がないため、ページ自身のアドレスに送信されます。
  • ページ ページネーションの各リンクは、同じクエリーに page を加えたものです(?sort=name&view=list&page=2)。現在のページのリンクには aria-current="page" が付きます。最初のページの「Previous」と最後のページの「Next」には href がなく、aria-disabled="true" が付きます。
  • サーバーが描画するもの 読み取った値を反映したフィールド(検索には value、チェックボックスと表示の切り替えには checked、並べ替えには selected)、そのページの結果、件数、そして一致するものがないときのサーバー側の空の状態です。条件が変わったら、page のない新しいクエリー、つまり最初のページになります。
  • スクリプトが加えるもの 利用者の入力やチェックに、サーバーとの往復なしで応答し、ページ番号を保持し、絞り込み条件をドロワーに移し、スクリプトがなければ動かない「Filters」ボタンと「Clear all」を表示します。条件は毎回 new FormData(form) でフォームから読み取り、コピーは持ちません。スクリプトが保持するのはページ番号だけです。このスクリプトを使い続けるプロジェクトでは、draw() をそのクエリーのリクエストに向け、同じクエリーを history.replaceState でアドレスに書き込みます。こうすると、再読み込みしても、共有されたリンクを開いても、同じ結果が表示されます。

この例は、フィルターバーの query.js から search、sort、paginate をインポートし、そのリクエストの代わりに使っています。これらはデモの一部であり、@master/ui の一部ではありません。ライブラリーはクエリーエンジンを公開していません。

#使い分け

  • 検索結果ページ は、見つかったものを 1 つずつ読み、それぞれが独自のページを持つ場合に使います。記事、ガイド、テンプレート、掲載情報、人物などです。
  • テーブルビュー は、行を列どうしで比較し、選択して一括操作する場合に使います。アプリケーションのページに置くブロックで、独自の検索、並べ替え、ページ送りを備えています。
  • フィルターバー は、1 つの条件がフィールド、比較、値からなり、複数の条件を組み合わせる場合に使います。チェックボックスのサイドバーは、常に表示しておく価値のある、少数の決まったグループに向いています。
  • ダッシュボード は、ページが要約を示す場合に使います。まず数値とチャートがあり、リストは詳細への入り口にすぎません。

#アクセシビリティ

  • ランドマークは、Main ナビゲーションを持つヘッダー、メイン領域、Resources という名前の検索フォーム、Pagination ナビゲーション、独自のナビゲーションを持つフッターです。最初のリンクはメイン領域へのスキップリンクで、メイン領域には tabindex="-1" を指定しています。
  • ソースの順序は、どの幅でも読む順序と同じです。タイトル、検索、絞り込み条件、件数と並べ替え、結果、ページの順です。ドロワーはメイン領域の最後に書かれており、開くまでは何の妨げにもなりません。
  • 種類は <legend> を持つ <fieldset> で、各件数はチェックボックスのラベルに含まれます。「Cards」と「List」の切り替えはネイティブのラジオボタンによる radiogroup、並べ替えはラベルを付けたネイティブの <select> です。
  • 件数には role="status" があるため、条件の変更は、フォーカスを動かさずに「4 of 12 resources」や「No resources match」のように読み上げられます。視覚的に隠した 2 つ目のステータスは、ページネーションのリンクが押された後にページと範囲を伝え、フォーカスは現在のページのリンクに残ります。
  • 結果は、視覚的に隠した <h2>「Results」の下にあり、各タイトルは <h3> です。そのため、結果へ直接移動し、結果から次の結果へと移動できます。カードのタイトルはそのリンク card-link で、カード全体がリンクのターゲットになります。
  • ドロワーは、タイトルを名前とするネイティブのモーダル <dialog> です。開くとフォーカスは最初のチェックボックスに移ります。Esc、外側の押下(closedby="any")、閉じるボタン、「Show results」で閉じ、フォーカスは「Filters」ボタンに戻ります。ボタンの名前は、適用中のフィルターの数を伝えます。
  • 「Clear all」と空の状態のボタンは、押されると自身を取り除くため、フォーカスは検索フィールドに移ります。