ナビゲーション

v2.1.0
タイポグラフィ

マーク

注目してほしい語句をハイライトします。

このページの内容

マークは、検索結果の一致箇所やレビューで指摘された語句など、その場で注目すべきテキストをハイライトします。専用の色は使わず、文字色を薄く敷くため、どの背景でも読みやすく、ステータス色の視認性も損ないません。ネイティブの<mark>に.markを指定します。

マーク

<ul class="flex flex-col gap-xs m(0) p(0) text-sm fg-text-body">  <li class="flex"><span><mark class="mark">Moon</mark>stone palette</span></li>  <li class="flex"><span>Half-<mark class="mark">moon</mark> icon</span></li>  <li class="flex"><span>Phases of the <mark class="mark">moon</mark>, a field guide</span></li></ul>
<ul className="flex flex-col gap-xs m(0) p(0) text-sm fg-text-body">  <li className="flex"><span><mark className="mark">Moon</mark>stone palette</span></li>  <li className="flex"><span>Half-<mark className="mark">moon</mark> icon</span></li>  <li className="flex">    <span>Phases of the <mark className="mark">moon</mark>, a field guide</span>  </li></ul>
<ul class="flex flex-col gap-xs m(0) p(0) text-sm fg-text-body">  <li class="flex"><span><mark class="mark">Moon</mark>stone palette</span></li>  <li class="flex"><span>Half-<mark class="mark">moon</mark> icon</span></li>  <li class="flex"><span>Phases of the <mark class="mark">moon</mark>, a field guide</span></li></ul>
<template>  <ul class="flex flex-col gap-xs m(0) p(0) text-sm fg-text-body">    <li class="flex"><span><mark class="mark">Moon</mark>stone palette</span></li>    <li class="flex"><span>Half-<mark class="mark">moon</mark> icon</span></li>    <li class="flex"><span>Phases of the <mark class="mark">moon</mark>, a field guide</span></li>  </ul></template>

リストボックス、コンボボックス、コマンドパレットでは、入力に合わせて各選択肢の一致箇所をマークで囲みます。

#現在の一致箇所

ページ内検索のように一致箇所を順にたどる場合は、現在の箇所にaria-current="true"を指定します。背景が文字色で塗りつぶされます。

現在の一致箇所

<p class="m(0) max-w(420) text-sm leading-md fg-text-body">  Corners nest by their <mark class="mark">inset</mark>: a container's radius is its content's radius plus the <mark class="mark" aria-current="true">inset</mark> between them, so the gap keeps one width around the bend. A button 4px inside a well takes the well's radius minus that <mark class="mark">inset</mark>.</p>
<p className="m(0) max-w(420) text-sm leading-md fg-text-body">  Corners nest by their <mark className="mark">inset</mark>: a container's radius is its content's radius plus the <mark className="mark" aria-current="true">inset</mark> between them, so the gap keeps one width around the bend. A button 4px inside a well takes the well's radius minus that <mark className="mark">inset</mark>.</p>
<p class="m(0) max-w(420) text-sm leading-md fg-text-body">  Corners nest by their <mark class="mark">inset</mark>: a container's radius is its content's radius plus the <mark class="mark" aria-current="true">inset</mark> between them, so the gap keeps one width around the bend. A button 4px inside a well takes the well's radius minus that <mark class="mark">inset</mark>.</p>
<template>  <p class="m(0) max-w(420) text-sm leading-md fg-text-body">    Corners nest by their <mark class="mark">inset</mark>: a container's radius is its content's radius plus the <mark class="mark" aria-current="true">inset</mark> between them, so the gap keeps one width around the bend. A button 4px inside a well takes the well's radius minus that <mark class="mark">inset</mark>.  </p></template>

#ブランドカラーと下線

mark-brandはブランドカラーを薄く敷き、ページの主題となるひとつの語句を強調します。mark-underlineは文字の下に太い下線を引きます。ブラウザーが文字の背面に描画し、折り返した先の行にも下線が付きます。

ブランドカラーと下線

<p class="m(0) max-w(420) text-md leading-md fg-text-strong">  Native HTML and CSS components with <mark class="mark mark-brand">no runtime</mark>, built on the platform and <mark class="mark mark-underline">finished by hand, one component at a time</mark>.</p>
<p className="m(0) max-w(420) text-md leading-md fg-text-strong">  Native HTML and CSS components with <mark className="mark mark-brand">no runtime</mark>, built on the platform and <mark className="mark mark-underline">finished by hand, one component at a time</mark>.</p>
<p class="m(0) max-w(420) text-md leading-md fg-text-strong">  Native HTML and CSS components with <mark class="mark mark-brand">no runtime</mark>, built on the platform and <mark class="mark mark-underline">finished by hand, one component at a time</mark>.</p>
<template>  <p class="m(0) max-w(420) text-md leading-md fg-text-strong">    Native HTML and CSS components with <mark class="mark mark-brand">no runtime</mark>, built on the platform and <mark class="mark mark-underline">finished by hand, one component at a time</mark>.  </p></template>

#アクセシビリティ

  • <mark>は「この文脈に関連する」ことを示します。重要性を示すには<strong>を使います。ほとんどのスクリーンリーダーはマークを読み上げないため、結果の意味がハイライトだけに頼らず伝わるようにします。
  • マークは元の文字色を維持し、その色を不透明度約10%で背景に敷くため、コントラストを保てます。強制カラーモードでは、システムのMarkとMarkTextを使います。
  • マークが折り返されても、各行のパディングと角丸は維持されます。

#クラス

クラス説明
mark周囲のテキストと同じ色を語句の背景に淡く適用
mark-brandページの主題を表す 1 つの語句に使う、淡いブランド色の背景mark と併用します
mark-underline語句の背景を塗る代わりに、語句の下端に引く太い線mark と併用します

#ソース

@master/ui/components/mark.css
/* * Mark: a stroke of highlighter over the words that matter, such as the part of a result that matches * a search. It is a wash of ink, not a hue: it reads on every surface and never competes with status colors. * A holder of results may set --mark-ink and --mark-weight, as an option of a listbox does. * The match a reader has stepped to is filled with ink. The wash, the stroke and the fill are read through * --mark-tone, --mark-line, --mark-fill, --mark-fill-ink and --mark-fill-text, which a surface of ink sets with @apply --on-ink, * so a mark in a tooltip or a sent message is drawn from that surface's own text color. */@layer components.ui {  .mark {    margin-inline: -.125em;    padding: .0625em .125em;    border-radius: calc(.1875rem * var(--corner-scale));    corner-shape: var(--corner-shape);    background: var(--mark-tone, var(--color-mark));    /* A list of results sets --mark-ink and --mark-weight, so a match keeps the title's ink inside a muted line. */    color: var(--mark-ink, inherit);    font-weight: var(--mark-weight, inherit);    box-decoration-break: clone;    -webkit-box-decoration-break: clone;    /* Brand: a wash of the brand color, for the one phrase a page is about. */    &.mark-brand {      background: color-mix(in oklab, var(--color-brand) 18%, transparent);    }    /*     * The current match among several: set aria-current="true" on it as the reader steps through. It follows the     * brand wash, so a current brand match is filled with ink too and its inverse words stay legible.     */    &[aria-current="true"] {      background: var(--mark-fill, var(--color-surface-inverse));      color: var(--mark-fill-ink, var(--color-text-inverse));      -webkit-text-fill-color: var(--mark-fill-text, currentColor);    }    /*     * Underline: the stroke runs along the foot of the words instead of over them. It is a thick underline,     * which the browser paints behind the letters and carries across line breaks.     */    &.mark-underline {      margin-inline: 0;      padding: 0;      border-radius: 0;      background: none;      /* Longhands: the compiler orders declarations, and the shorthand would reset the thickness after it. */      text-decoration-line: underline;      text-decoration-thickness: .4em;      text-decoration-color: var(--mark-line, var(--color-mark-underline));      text-decoration-skip-ink: none;      text-underline-offset: -.18em;      /* The current match is filled with ink as any mark's is, and the stroke steps aside under it. */      &[aria-current="true"] {        /* The fill stands a little past the letters, as a wash's does, without moving them. */        margin-inline: -.125em;        padding: .0625em .125em;        border-radius: calc(.1875rem * var(--corner-scale));        background: var(--mark-fill, var(--color-surface-inverse));        text-decoration-color: transparent;      }    }    @media (forced-colors: active) {      background: Mark;      color: MarkText;      forced-color-adjust: none;      &.mark-brand {        background: Mark;      }      /* The stroke takes the mark's color, and the words over it keep the page's ink. */      &.mark-underline {        background: none;        color: CanvasText;        text-decoration-color: Mark;      }      &[aria-current="true"], &.mark-underline[aria-current="true"] {        background: Highlight;        color: HighlightText;        -webkit-text-fill-color: currentColor;        text-decoration-color: transparent;      }    }  }}