ナビゲーション

v2.1.0
タイポグラフィ

出典参照

文中で出典を示す、小さな番号付きマーカー。

このページの内容

出典参照は、記述の末尾からその出典を参照できる、小さな番号付きマーカーです。リンクをチップと同じ色のカプセル形で表示し、文字より少し小さく、ベースラインよりわずかに上に配置します。ポインターを重ねたときと出典の表示中は、インク色で塗りつぶされます。

出典参照

<div class="max-w(480) mx-auto text-sm fg-text-body leading-md">  <p class="m(0)">    Corners are drawn as squircles where the browser has <code class="code">corner-shape</code><button type="button" class="citation" popovertarget="source-1" aria-label="Source 1">1</button><span class="popover" id="source-1" popover>      <span class="flex flex-col gap-xs">        <span class="fg-text-strong font-medium">          CSS Borders and Box Decorations Module Level 4        </span><span class="fg-text-muted text-xs">W3C Working Draft · w3.org</span>      </span>    </span> and as circles elsewhere, with the radius scaled so both look equally round.<a class="citation" href="#ref-2" aria-label="Source 2">2</a><a class="citation" href="#ref-3" aria-label="Source 3">3</a>  </p>  <ol class="mt-md pl-md text-xs fg-text-muted">    <li>CSS Borders and Box Decorations Module Level 4</li>    <li id="ref-2">Master UI theme guide, “Continuous corners”</li>    <li id="ref-3">Figma, “Desperately seeking squircles”</li>  </ol></div>
<div className="max-w(480) mx-auto text-sm fg-text-body leading-md">  <p className="m(0)">    Corners are drawn as squircles where the browser has <code className="code">corner-shape</code><button type="button" className="citation" popoverTarget="source-1" aria-label="Source 1">      1    </button><span className="popover" id="source-1" popover="">      <span className="flex flex-col gap-xs">        <span className="fg-text-strong font-medium">          CSS Borders and Box Decorations Module Level 4        </span><span className="fg-text-muted text-xs">W3C Working Draft · w3.org</span>      </span>    </span> and as circles elsewhere, with the radius scaled so both look equally round.<a className="citation" href="#ref-2" aria-label="Source 2">2</a><a className="citation" href="#ref-3" aria-label="Source 3">3</a>  </p>  <ol className="mt-md pl-md text-xs fg-text-muted">    <li>CSS Borders and Box Decorations Module Level 4</li>    <li id="ref-2">Master UI theme guide, “Continuous corners”</li>    <li id="ref-3">Figma, “Desperately seeking squircles”</li>  </ol></div>
<div class="max-w(480) mx-auto text-sm fg-text-body leading-md">  <p class="m(0)">    Corners are drawn as squircles where the browser has <code class="code">corner-shape</code><button type="button" class="citation" popovertarget="source-1" aria-label="Source 1">1</button><span class="popover" id="source-1" popover>      <span class="flex flex-col gap-xs">        <span class="fg-text-strong font-medium">          CSS Borders and Box Decorations Module Level 4        </span><span class="fg-text-muted text-xs">W3C Working Draft · w3.org</span>      </span>    </span> and as circles elsewhere, with the radius scaled so both look equally round.<a class="citation" href="#ref-2" aria-label="Source 2">2</a><a class="citation" href="#ref-3" aria-label="Source 3">3</a>  </p>  <ol class="mt-md pl-md text-xs fg-text-muted">    <li>CSS Borders and Box Decorations Module Level 4</li>    <li id="ref-2">Master UI theme guide, “Continuous corners”</li>    <li id="ref-3">Figma, “Desperately seeking squircles”</li>  </ol></div>
<template>  <div class="max-w(480) mx-auto text-sm fg-text-body leading-md">    <p class="m(0)">      Corners are drawn as squircles where the browser has <code class="code">corner-shape</code><button type="button" class="citation" popovertarget="source-1" aria-label="Source 1">        1      </button><span class="popover" id="source-1" popover>        <span class="flex flex-col gap-xs">          <span class="fg-text-strong font-medium">            CSS Borders and Box Decorations Module Level 4          </span><span class="fg-text-muted text-xs">W3C Working Draft · w3.org</span>        </span>      </span> and as circles elsewhere, with the radius scaled so both look equally round.<a class="citation" href="#ref-2" aria-label="Source 2">2</a><a class="citation" href="#ref-3" aria-label="Source 3">3</a>    </p>    <ol class="mt-md pl-md text-xs fg-text-muted">      <li>CSS Borders and Box Decorations Module Level 4</li>      <li id="ref-2">Master UI theme guide, “Continuous corners”</li>      <li id="ref-3">Figma, “Desperately seeking squircles”</li>    </ol>  </div></template>
最初のマーカーはポップオーバーで出典を開き、残りは出典一覧へ移動します。

#参照先

出典の参照先は2通りあり、どちらもスクリプトなしで使えます。

  • 出典一覧は、通常、回答や記事の末尾に置きます。マーカーには<a>を使い、そのhrefに一覧項目のIDを指すフラグメントを指定します。
  • ポップオーバー に出典のタイトルと掲載元を表示します。マーカーにはpopovertargetを指定した<button>を使い、ポップオーバーの直前に置きます。ポップオーバーを開いている間は、マーカーが塗りつぶされたままになります。段落内に<div>は置けないため、段落内のポップオーバーには<span>を使います。

マーカーの前には空白を入れません。インライン要素なので、直前の語と一緒に折り返され、マーカーだけが行頭に来ることはありません。

#アクセシビリティ

  • 各マーカーには、番号だけでなく、参照先がわかるアクセシブルな名前が必要です。各マーカーに「出典2」や出典のタイトルなどをaria-labelで指定します。
  • マーカーを使わずに出典を確認できるようにします。ポップオーバーをいくつも開くより、一覧でひと目で確認できるほうが便利です。
  • マーカーは小さく、番号にはコントロールと同じ文字の太さで等幅数字を使います。操作領域は、マーカーを含むテキストのサイズに合わせて広がります。

#クラス

クラス説明
citationマークには、href が出典の id を指す<a>、または対応するポップオーバーの直前に記述した popovertarget 付きの<button>を使います。「出典 2」などのaria-labelを付けます。

#ソース

@master/ui/components/citation.css
/* * Citation: a small numbered mark in a sentence that points at where the sentence came from. * It is a link: a chip-toned pill a little smaller than the text and raised a little above its baseline, * with the number in tabular figures. It stays inline, so it wraps with the word it follows. Under the pointer, and while the source it opens is showing, it * fills with ink. The source itself is a popover or a list at the foot of the answer. */@layer components.ui {  .citation {    user-select: none;    -webkit-user-select: none;    /* Inline, not a box of its own: with no space before it, it never starts a line apart from its word. */    display: inline;    margin-inline: .2em .05em;    padding: .25em .5em;    border: 0;    border-radius: 999px;    corner-shape: round;    background: var(--citation-tone, var(--color-surface-chip));    color: var(--citation-ink, var(--color-text-body));    box-shadow: inset 0 0 0 .5px var(--citation-line, var(--color-line-contour));    font: var(--font-weight-control) .6875em/1 var(--font-family-sans);    font-feature-settings: inherit;    font-variant-numeric: tabular-nums;    letter-spacing: 0;    text-decoration: none;    white-space: nowrap;    vertical-align: .22em;    appearance: none;    cursor: pointer;    -webkit-tap-highlight-color: transparent;    /* It answers the pointer at once, as a row in a list does. */    @media (hover: hover) {      &:hover {        background: var(--citation-fill, var(--color-surface-inverse));        color: var(--citation-fill-ink, var(--color-text-inverse));        -webkit-text-fill-color: var(--citation-fill-text, currentColor);        box-shadow: none;      }    }    /* The mark under a press, the one whose source is open, or the one a reader has just followed. */    &:is(:active, [aria-expanded="true"], [aria-current="true"], :has(+ .popover:popover-open)) {      background: var(--citation-fill, var(--color-surface-inverse));      color: var(--citation-fill-ink, var(--color-text-inverse));      -webkit-text-fill-color: var(--citation-fill-text, currentColor);      box-shadow: none;    }    /* The theme's ring, at the offset a link's takes. */    &:focus-visible {      @apply --focus-ring;    }    @media (forced-colors: active) {      outline: 1px solid LinkText;      outline-offset: -1px;      color: LinkText;      /* The fill of an open or followed mark is gone with its colors: it takes the link color as its face. */      &:is([aria-expanded="true"], [aria-current="true"], :has(+ .popover:popover-open)) {        background: LinkText;        color: Canvas;        forced-color-adjust: none;      }      /* The words keep the system's colors, whatever face an ink surface would paint them in. */      &:is(:hover, :active, [aria-expanded="true"], [aria-current="true"], :has(+ .popover:popover-open)) {        -webkit-text-fill-color: currentColor;      }      /* A filled mark is kept out of forced colors, so its ring is given the system's color here. */      &:focus-visible {        outline: 2px solid Highlight;        outline-offset: 2px;      }    }  }}