網站導覽

v2.1.0
文字排版

提及

句子中被點名的人、團隊或事物。

本頁內容

提及用於在句子裡點名某個人、團隊或事物,例如 @Ada、#design 或議題編號。它沿用句子的字型和文字顏色,採用控制項的字重,並以淡淡的同色底襯托。提及沒有外框,因此可和行內程式碼區分。

提及

<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> 上時,提及可連到個人資料或議題,指標移到上方時底色會加深。用在 <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;    }  }}