ナビゲーション

v2.1.0
タイポグラフィ

メンション

文中で人やチーム、項目を指し示します。

このページの内容

メンションは、@Adaや#design、Issue番号のように、文中で人やチーム、項目を指し示します。本文と同じ書体と文字色を使い、ウェイトはコントロールと揃え、文字色を薄く敷きます。輪郭がないため、インラインコードと見分けられます。

メンション

<div class="flex flex-col max-w(440) mx-auto">  <div class="message">    <div class="message-bubble">      <a class="mention" href="#">@Ada Lovelace</a> the build for <a class="mention" href="#">#412</a> is green. Can <a class="mention mention-self" href="#">@you</a> review it before <span class="mention">Friday</span>?    </div>  </div>  <div class="message message-sent">    <div class="message-bubble">      On it. I will loop in <a class="mention" href="#">@design</a> for the corners.    </div>  </div></div>
<div className="flex flex-col max-w(440) mx-auto">  <div className="message">    <div className="message-bubble">      <a className="mention" href="#">@Ada Lovelace</a> the build for <a className="mention" href="#">#412</a> is green. Can <a className="mention mention-self" href="#">@you</a> review it before <span className="mention">Friday</span>?    </div>  </div>  <div className="message message-sent">    <div className="message-bubble">      On it. I will loop in <a className="mention" href="#">@design</a> for the corners.    </div>  </div></div>
<div class="flex flex-col max-w(440) mx-auto">  <div class="message">    <div class="message-bubble">      <a class="mention" href="#">@Ada Lovelace</a> the build for <a class="mention" href="#">#412</a> is green. Can <a class="mention mention-self" href="#">@you</a> review it before <span class="mention">Friday</span>?    </div>  </div>  <div class="message message-sent">    <div class="message-bubble">      On it. I will loop in <a class="mention" href="#">@design</a> for the corners.    </div>  </div></div>
<template>  <div class="flex flex-col max-w(440) mx-auto">    <div class="message">      <div class="message-bubble">        <a class="mention" href="#">@Ada Lovelace</a> the build for <a class="mention" href="#">#412</a> is green. Can <a class="mention mention-self" href="#">@you</a> review it before <span class="mention">Friday</span>?      </div>    </div>    <div class="message message-sent">      <div class="message-bubble">        On it. I will loop in <a class="mention" href="#">@design</a> for the corners.      </div>    </div>  </div></template>

<a>でマークアップすると、プロフィールやIssueなどへのリンクになり、ホバー時には背景色が濃くなります。<span>でマークアップすると、パーサーが認識した日付などを、文中で区別して表示できます。スタイルシートは:any-linkで両者を区別し、移動先のあるメンションだけがリンクに見えるようにします。

#読者自身へのメンション

mention-selfは読者自身へのメンションを示します。背景色を少し濃くし、細い輪郭線を付けることで、長いスレッドでも自分の名前を見つけやすくします。文字色はほかのメンションと共通で、色調の差は控えめにしているため、本文には「あなた」や名前を明記します。

#文中での表示

メンションの途中では改行しません。背景色と細い輪郭線の色は現在の文字色をもとに作るため、周囲の文が読めるところならメンションも読みやすく表示されます。たとえば、本文の文字色を背景に使う送信メッセージでは、吹き出し内の明るい文字色で名前を表示し、その文字色を背景に薄く敷きます。

#アクセシビリティ

  • 記号もテキストの一部です。コピーや読み上げでも同じメンションになるよう、要素内に@または#を記述します。
  • プロフィールを開くメンションはリンクです。追加のロールは不要です。

#クラス

クラス説明
mention名前には本文と同じ書体と文字色を使い、フォントの太さはコントロールに合わせます。背景には文字色を淡く重ねます。名前の途中では改行されず、リンクの場合はポインターを重ねると背景色が濃くなります。
mention-self読み手本人の名前。やや濃い色合いと極細の罫線で示します。mention と併用します

#ソース

@master/ui/components/mention.css
/* * Mention: a person, a team or a thing named inside a sentence: @Ada, #design, an issue's number. * It is the sentence's own type and its own ink at the control weight, on a faint tint of that ink, with no * contour, which tells it apart from inline code. Because the tint and the hairline are mixed from the * current color, a mention reads on any surface: a page, a card, the ink of a sent message. * As a link it deepens under the pointer. mention-self marks the reader's own name with a firmer tint and a * hairline, so it is found at a glance in a long thread. */@layer components.ui {  .mention {    --mention-tint: 7%;    padding: .0625em .3125em;    border-radius: calc((var(--radius-chip) - 2px) * var(--corner-scale));    corner-shape: var(--corner-shape);    background: color-mix(in oklab, currentColor var(--mention-tint), transparent);    color: inherit;    font-weight: var(--font-weight-control);    text-decoration: none;    white-space: nowrap;    -webkit-box-decoration-break: clone;    box-decoration-break: clone;    @media (hover: hover) {      &:any-link:hover {        --mention-tint: 13%;      }    }    /* Pressed: the same deeper tint, so a tap on a touch screen is answered too. */    &:any-link:active {      --mention-tint: 13%;    }    &:focus-visible {      outline: 2px solid var(--color-focus);      outline-offset: 2px;    }    &.mention-self {      --mention-tint: 12%;      box-shadow: inset 0 0 0 .5px color-mix(in oklab, currentColor 28%, transparent);      /* Its own tint is already firmer, so as a link it deepens from there. */      @media (hover: hover) {        &:any-link:hover {          --mention-tint: 18%;        }      }      &:any-link:active {        --mention-tint: 18%;      }    }    @media (forced-colors: active) {      outline: 1px solid CanvasText;      outline-offset: -1px;    }  }}