ナビゲーション

v2.1.0
メディア

ウィンドウ

スクリーンショット、デモ、ターミナルを囲むアプリケーション風のフレーム。

このページの内容

ウィンドウは、スクリーンショットや短いデモ、数行のターミナル出力など、見せたい内容を囲むアプリケーション風のフレームです。浮き上がったシートの上端にバーが付きます。バーの 3 つのマークには輪郭線と同じ無彩色を使い、ウィンドウだと分かる形を保ちながら、中身の色を引き立てます。

ウィンドウ

<figure class="window max-w(520) mx-auto">  <div class="window-bar">    <span class="window-controls" aria-hidden="true"></span>    <span class="window-title">Atlas · Deployments</span>  </div>  <img class="window-body object-cover w-full" style="aspect-ratio: 16 / 10" src="/demo/moonstone.svg" alt="The deployments view of Atlas"></figure>
<figure className="window max-w(520) mx-auto">  <div className="window-bar">    <span className="window-controls" aria-hidden="true"></span>    <span className="window-title">Atlas · Deployments</span>  </div>  <img className="window-body object-cover w-full" style={{ aspectRatio: '16 / 10' }} src="/demo/moonstone.svg" alt="The deployments view of Atlas" /></figure>
<figure class="window max-w(520) mx-auto">  <div class="window-bar">    <span class="window-controls" aria-hidden="true"></span>    <span class="window-title">Atlas · Deployments</span>  </div>  <img class="window-body object-cover w-full" style="aspect-ratio: 16 / 10" src="/demo/moonstone.svg" alt="The deployments view of Atlas"></figure>
<template>  <figure class="window max-w(520) mx-auto">    <div class="window-bar">      <span class="window-controls" aria-hidden="true"></span>      <span class="window-title">Atlas · Deployments</span>    </div>    <img class="window-body object-cover w-full" style="aspect-ratio: 16 / 10" src="/demo/moonstone.svg" alt="The deployments view of Atlas">  </figure></template>

#バー

window-bar には 3 つの配置位置があります。先頭の window-controls は 1 つの空要素で、3 つの円として描画されます。中央には window-title、またはブラウザーのアドレス欄のように少しくぼんだ window-address を置きます。末尾には window-end で任意の内容を配置できます。どの部分も省略でき、両脇の内容にかかわらず、中央の要素はバーの中央に揃います。

アドレス欄

<figure class="window max-w(520) mx-auto">  <div class="window-bar">    <span class="window-controls" aria-hidden="true"></span>    <span class="window-address">      <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <rect x="3" y="7" width="10" height="7" rx="1" /><path d="M5.5 7V4.5A2.5 2.5 0 0 1 10.5 4.5V7" /><path d="M8 9.5L8 11" />      </svg>atlas.dev/deployments    </span>    <span class="window-end"><span class="badge badge-sm badge-success badge-dot">Live</span></span>  </div>  <div class="window-body flex flex-col gap-sm p-lg">    <div class="skeleton skeleton-text w(180)"></div>    <div class="skeleton skeleton-text"></div>    <div class="skeleton skeleton-text w(320)"></div>    <div class="skeleton h(96) mt-xs"></div>  </div></figure>
import LockIcon from '@master/icons-react/native/16/soft/lock'<figure className="window max-w(520) mx-auto">  <div className="window-bar">    <span className="window-controls" aria-hidden="true"></span>    <span className="window-address"><LockIcon className="icon" />atlas.dev/deployments</span>    <span className="window-end">      <span className="badge badge-sm badge-success badge-dot">Live</span>    </span>  </div>  <div className="window-body flex flex-col gap-sm p-lg">    <div className="skeleton skeleton-text w(180)"></div>    <div className="skeleton skeleton-text"></div>    <div className="skeleton skeleton-text w(320)"></div>    <div className="skeleton h(96) mt-xs"></div>  </div></figure>
<script>  import LockIcon from '@master/icons-svelte/native/16/soft/lock'</script><figure class="window max-w(520) mx-auto">  <div class="window-bar">    <span class="window-controls" aria-hidden="true"></span>    <span class="window-address"><LockIcon class="icon" />atlas.dev/deployments</span>    <span class="window-end"><span class="badge badge-sm badge-success badge-dot">Live</span></span>  </div>  <div class="window-body flex flex-col gap-sm p-lg">    <div class="skeleton skeleton-text w(180)"></div>    <div class="skeleton skeleton-text"></div>    <div class="skeleton skeleton-text w(320)"></div>    <div class="skeleton h(96) mt-xs"></div>  </div></figure>
<script setup>import LockIcon from '@master/icons-vue/native/16/soft/lock'</script><template>  <figure class="window max-w(520) mx-auto">    <div class="window-bar">      <span class="window-controls" aria-hidden="true"></span>      <span class="window-address"><LockIcon class="icon" />atlas.dev/deployments</span>      <span class="window-end">        <span class="badge badge-sm badge-success badge-dot">Live</span>      </span>    </div>    <div class="window-body flex flex-col gap-sm p-lg">      <div class="skeleton skeleton-text w(180)"></div>      <div class="skeleton skeleton-text"></div>      <div class="skeleton skeleton-text w(320)"></div>      <div class="skeleton h(96) mt-xs"></div>    </div>  </figure></template>

#本体

window-body にはパディングがないため、画像や動画はフレームの縁まで広がり、ウィンドウの角の丸みに沿って切り抜かれます。テキストにはパディングのユーティリティで余白を設けます。このクラスは、コンテンツ本体の <img>、<video>、<pre>、<div> などの要素に指定します。

window-flat は輪郭線を 1 本だけ残し、影を省きます。トレイの上や、情報量の多いページでほかの要素と並べる場合に適しています。

ターミナル

<figure class="window window-flat max-w(520) mx-auto">  <div class="window-bar">    <span class="window-controls" aria-hidden="true"></span>    <span class="window-title">zsh</span>  </div>  <pre class="window-body p-md font-mono text-xs leading-lg fg-text-strong overflow-x-auto"><span class="fg-text-muted">$</span> npm install @master/css @master/ui<span class="fg-text-muted">added 2 packages in 1.4s</span><span class="fg-text-muted">$</span> npm run dev</pre></figure>
<figure class="window window-flat max-w(520) mx-auto">  <div class="window-bar">    <span class="window-controls" aria-hidden="true"></span>    <span class="window-title">zsh</span>  </div>  <pre class="window-body p-md font-mono text-xs leading-lg fg-text-strong overflow-x-auto"><span class="fg-text-muted">$</span> npm install @master/css @master/ui<span class="fg-text-muted">added 2 packages in 1.4s</span><span class="fg-text-muted">$</span> npm run dev</pre></figure>
<template>  <figure class="window window-flat max-w(520) mx-auto">    <div class="window-bar">      <span class="window-controls" aria-hidden="true"></span>      <span class="window-title">zsh</span>    </div>    <pre class="window-body p-md font-mono text-xs leading-lg fg-text-strong overflow-x-auto"><span class="fg-text-muted">$</span> npm install @master/css @master/ui<span class="fg-text-muted">added 2 packages in 1.4s</span><span class="fg-text-muted">$</span> npm run dev</pre>  </figure></template>

#アクセシビリティ

  • フレームは装飾です。3 つの円は操作できない装飾なので、window-controls を aria-hidden="true" で支援技術から隠します。
  • 本文を補足するウィンドウには <figure> が適しています。画像に説明が必要なら、同じ図版の中でウィンドウの後に <figcaption> を追加します。
  • スクリーンショットの内容は、画像の alt に記述します。バーのタイトルは画像の一部なので、画像の説明は別に記述します。
  • このコンポーネントは表示専用です。ページに重ねて開く操作可能なウィンドウには、ダイアログを使います。

#クラス

クラス説明
windowフレームは、角丸 12px の浮いたシートで、はみ出した内容を切り取ります。
window-flat輪郭1本、影なし。トレイ上や密度の高いページ内のウィンドウ向けwindow と併用します
window-bar上部を横切るバー。先頭にマーク、中央にタイトルまたはアドレス、末尾にコントロール用のスペース
window-controlsバーの先頭に、1つの空要素で3つの印を描きます。その要素には aria-hidden="true" を指定して、アクセシビリティツリーから除外します。
window-titleバーの中央に 1 行で表示するタイトル
window-addressタイトルの代わりに、バー中央の小さなくぼみに表示するアドレス
window-endバーの末尾に置く内容
window-bodyウィンドウの表示内容。画像、動画、pre、または div。パディングなし

#カスタムプロパティ

プロパティ既定値説明
--window-radiusvar(--radius-control-lg)フレームの角の丸み
--window-bar-height2.5remバーの高さ

#ソース

@master/ui/components/window.css
/* * Window: the frame of an application around a screenshot, a demo or a few lines of a terminal. * A lifted sheet with a 12px corner. Its bar is a quieter tone over a hairline and carries three marks at * the start, drawn from one element in the ink of a line, with no hue: the frame says "this is a window" * and leaves the color to what it shows. A title stands in the middle of the bar, or an address in a small * well. The body is cut by the window's own corner, so a picture runs to the edge. */@layer components.ui {  .window {    --window-radius: var(--radius-control-lg);    --window-bar-height: 2.5rem;    --surface-color: var(--color-surface-raised);    position: relative;    display: flex;    flex-direction: column;    min-width: 0;    margin: 0;    border-radius: calc(var(--window-radius) * var(--corner-scale));    corner-shape: var(--corner-shape);    /* The bar's tone and a picture in the body are finished by the window's corner. */    overflow: clip;    background: var(--color-surface-raised);    color: var(--color-text-body);    box-shadow: var(--shadow-lifted);    /* One contour and no lift, for a window on a tray or in a dense page. */    &.window-flat {      box-shadow: var(--shadow-flat);    }    @media (forced-colors: active) {      outline: 1px solid CanvasText;      outline-offset: -1px;    }  }  /* The bar: the marks at the start, the title or the address in the middle, and room for a control at the end. */  .window-bar {    display: grid;    flex: none;    /* The sides never shrink below what they hold, so a long title is cut instead of running under the marks. */    grid-template-columns: minmax(min-content, 1fr) auto minmax(min-content, 1fr);    align-items: center;    gap: .75rem;    min-height: var(--window-bar-height);    padding: 0 .875rem;    border-block-end: 1px solid var(--color-line-hair);    @apply --surface-sheet;    box-shadow: inset 0 1px 0 var(--color-highlight);  }  /* Three marks, 11px each, 8px apart: discs of the line ink with a faint edge of their own. */  .window-controls {    --window-mark: var(--color-line-strong);    display: block;    width: 3.0625rem;    height: .6875rem;    background:      radial-gradient(circle at 5.5px 50%, var(--window-mark) 5px, transparent 5.5px),      radial-gradient(circle at 24.5px 50%, var(--window-mark) 5px, transparent 5.5px),      radial-gradient(circle at 43.5px 50%, var(--window-mark) 5px, transparent 5.5px);    @media (forced-colors: active) {      --window-mark: CanvasText;      forced-color-adjust: none;    }  }  .window-title {    grid-column: 2;    max-width: 100%;    margin: 0;    overflow: hidden;    color: var(--color-text-muted);    font: var(--font-weight-control) .8125rem/1.2 var(--font-family-sans);    font-feature-settings: inherit;    text-align: center;    text-overflow: ellipsis;    white-space: nowrap;  }  /* An address instead of a title: a small well in the middle of the bar, as a browser has. */  .window-address {    --icon-size: .75rem;    display: inline-flex;    grid-column: 2;    align-items: center;    /* An address longer than the well keeps its start in view and is cut at its end. */    justify-content: safe center;    gap: .375rem;    width: min(100%, 16rem);    min-width: 0;    height: 1.625rem;    padding: 0 .75rem;    border-radius: calc((var(--window-radius) - .25rem) * var(--corner-scale));    corner-shape: var(--corner-shape);    overflow: hidden;    background: var(--color-surface-inset);    color: var(--color-text-muted);    box-shadow: var(--shadow-pressed);    font: 400 .75rem/1 var(--font-family-sans);    font-feature-settings: inherit;    text-overflow: ellipsis;    white-space: nowrap;    /* Shadows are not drawn here, so the well keeps its edge as a rule. */    @media (forced-colors: active) {      outline: 1px solid CanvasText;      outline-offset: -1px;    }  }  /* What stands at the end of the bar. */  .window-end {    display: inline-flex;    grid-column: 3;    align-items: center;    justify-content: flex-end;    gap: .25rem;    min-width: 0;    color: var(--color-text-muted);  }  /* What the window shows. It has no padding: a picture or a video meets the frame. */  .window-body {    display: block;    flex: 1 1 auto;    min-width: 0;    min-height: 0;    margin: 0;  }}