網站導覽

v2.1.0
文字排版

指令片段

一行可複製的指令,附有終端機提示符號和複製按鈕。

本頁內容

指令片段包含一行可在終端機執行的指令、終端機提示符號,以及複製指令的按鈕。它和程式碼區塊一樣採用等寬字型和凹槽樣式,高度則與按鈕相同,可與按鈕並排。提示符號無法選取,指令維持單行,複製按鈕距尾端 4px,指標移上去時才會更醒目。

指令片段

<div class="snippet max-w(360) mx-auto">  <span class="snippet-prompt" aria-hidden="true">$</span>  <code class="snippet-command" tabindex="0">npm install @master/ui</code>  <button type="button" class="btn btn-quiet btn-square" aria-label="Copy command">    <svg class="icon snippet-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">      <path d="M3 1.5H9A1.4999 1.4999 0 0 1 10.5 3V4.25H9.5V3A0.5002 0.5002 0 0 0 9 2.5H3A0.5002 0.5002 0 0 0 2.5 3V9A0.5002 0.5002 0 0 0 3 9.5H4.25V10.5H3A1.4999 1.4999 0 0 1 1.5 9V3A1.4999 1.4999 0 0 1 3 1.5Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><rect x="5.5" y="5.5" width="8.5" height="8.5" rx="1" />    </svg>    <svg class="icon snippet-check" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">      <path d="M3 8L6.3532 11.3532A0.2 0.2 0 0 0 6.6412 11.3479L13 4.5" />    </svg>  </button>  <output class="snippet-status"></output></div><script>document.querySelectorAll('.snippet').forEach(function (snippet) {var status = snippet.querySelector('.snippet-status')var timer = 0snippet.querySelector('.btn').addEventListener('click', function () {  var command = Array.prototype.find.call(snippet.querySelectorAll('.snippet-command'), function (line) {    return line.checkVisibility()  })  navigator.clipboard.writeText(command.textContent).then(function () {    status.textContent = 'Copied'    clearTimeout(timer)    timer = setTimeout(function () { status.textContent = '' }, 2000)  })})})</script>
複製指令後,圖示會變成勾號並維持兩秒。

#指令列

snippet 分成三欄。第一欄的 snippet-prompt 是終端機顯示在指令前的符號,例如 $ 或 >,以較淡的顏色呈現。這個符號無法選取,手動選取整行時只會選到指令,也會用 aria-hidden 避免螢幕閱讀器讀出。第二欄放指令本身,以帶有 snippet-command 的 <code> 呈現。最後一欄放低調的方形按鈕,高度和圓角都由指令片段設定,按鈕在指令列上下各留 4px。

指令超出可用寬度時會維持單行,並可左右捲動,捲動條則隱藏。還有內容的那一側會淡出。淡出效果取決於捲動位置,因此在開始捲動前,起始側會保持清晰。為指令加上 tabindex="0",讓使用者能用方向鍵捲動。指令取得焦點時,整列都會顯示焦點外框。

較長的指令

<div class="snippet max-w(360) mx-auto">  <span class="snippet-prompt" aria-hidden="true">$</span>  <code class="snippet-command" tabindex="0">    curl -fsSL https://ui.master.co/install.sh | sh -s -- --yes --prefix ~/.local  </code>  <button type="button" class="btn btn-quiet btn-square" aria-label="Copy command">    <svg class="icon snippet-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">      <path d="M3 1.5H9A1.4999 1.4999 0 0 1 10.5 3V4.25H9.5V3A0.5002 0.5002 0 0 0 9 2.5H3A0.5002 0.5002 0 0 0 2.5 3V9A0.5002 0.5002 0 0 0 3 9.5H4.25V10.5H3A1.4999 1.4999 0 0 1 1.5 9V3A1.4999 1.4999 0 0 1 3 1.5Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><rect x="5.5" y="5.5" width="8.5" height="8.5" rx="1" />    </svg>    <svg class="icon snippet-check" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">      <path d="M3 8L6.3532 11.3532A0.2 0.2 0 0 0 6.6412 11.3479L13 4.5" />    </svg>  </button>  <output class="snippet-status"></output></div><script>document.querySelectorAll('.snippet').forEach(function (snippet) {var status = snippet.querySelector('.snippet-status')var timer = 0snippet.querySelector('.btn').addEventListener('click', function () {  var command = Array.prototype.find.call(snippet.querySelectorAll('.snippet-command'), function (line) {    return line.checkVisibility()  })  navigator.clipboard.writeText(command.textContent).then(function () {    status.textContent = 'Copied'    clearTimeout(timer)    timer = setTimeout(function () { status.textContent = '' }, 2000)  })})})</script>
左右捲動指令。哪一側還有內容,該側邊緣就會淡出。

#複製指令

複製功能需要透過腳本將指令文字交給 navigator.clipboard。複製狀態不靠切換類別,而是由按鈕旁起初為空的 <output> 元素 snippet-status 表示。使用者看不到這個元素。腳本寫入「已複製」後,螢幕閱讀器會朗讀,兩秒後腳本再清空文字。只要狀態有文字,樣式表就會把複製圖示換成勾號,讓畫面和朗讀傳達相同的訊息。

預覽中的腳本包含完整流程:找出目前顯示的指令、寫入剪貼簿,再填入並清空狀態訊息。只有透過 HTTPS 提供的頁面或來自 localhost 的頁面可存取剪貼簿。腳本停用時,複製按鈕會隱藏,仍可手動選取並複製指令文字。

#套件管理工具

若要為 npm、pnpm、bun 和 yarn 提供同一項操作的指令,請在片段開頭放入由原生單選按鈕組成的分段控制項,再依照選項順序為每個選項寫一個 snippet-command。分段控制項會省略自己的凹槽,沿片段頂部排列,下方以細線分隔。選取的選項會凸起,切換時凸起面板會滑到新選項。元件只顯示與選取位置對應的指令,無需腳本,最多支援六個選項。

套件管理工具

<div class="snippet max-w(360) mx-auto">  <div class="segmented" role="radiogroup" aria-label="Package manager">    <label class="segmented-item">      <input class="segmented-input" type="radio" name="manager" checked>npm    </label>    <label class="segmented-item">      <input class="segmented-input" type="radio" name="manager">pnpm    </label>    <label class="segmented-item">      <input class="segmented-input" type="radio" name="manager">bun    </label>    <label class="segmented-item">      <input class="segmented-input" type="radio" name="manager">yarn    </label>  </div>  <span class="snippet-prompt" aria-hidden="true">$</span>  <code class="snippet-command" tabindex="0">npm install @master/ui</code>  <code class="snippet-command" tabindex="0">pnpm add @master/ui</code>  <code class="snippet-command" tabindex="0">bun add @master/ui</code>  <code class="snippet-command" tabindex="0">yarn add @master/ui</code>  <button type="button" class="btn btn-quiet btn-square" aria-label="Copy command">    <svg class="icon snippet-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">      <path d="M3 1.5H9A1.4999 1.4999 0 0 1 10.5 3V4.25H9.5V3A0.5002 0.5002 0 0 0 9 2.5H3A0.5002 0.5002 0 0 0 2.5 3V9A0.5002 0.5002 0 0 0 3 9.5H4.25V10.5H3A1.4999 1.4999 0 0 1 1.5 9V3A1.4999 1.4999 0 0 1 3 1.5Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><rect x="5.5" y="5.5" width="8.5" height="8.5" rx="1" />    </svg>    <svg class="icon snippet-check" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">      <path d="M3 8L6.3532 11.3532A0.2 0.2 0 0 0 6.6412 11.3479L13 4.5" />    </svg>  </button>  <output class="snippet-status"></output></div><script>document.querySelectorAll('.snippet').forEach(function (snippet) {var status = snippet.querySelector('.snippet-status')var timer = 0snippet.querySelector('.btn').addEventListener('click', function () {  var command = Array.prototype.find.call(snippet.querySelectorAll('.snippet-command'), function (line) {    return line.checkVisibility()  })  navigator.clipboard.writeText(command.textContent).then(function () {    status.textContent = 'Copied'    clearTimeout(timer)    timer = setTimeout(function () { status.textContent = '' }, 2000)  })})})</script>
選擇套件管理工具,即可切換這一行顯示的指令。

#尺寸

指令列高 38px,與按鈕同高。snippet-sm 高 32px,字級為 12px,適合資訊密集的頁面或表格。snippet-lg 高 44px,字級為 14px,適合放在頁面頂部與大型按鈕並排。在觸控螢幕上,所有尺寸都維持原本的高度,複製按鈕的觸控區則在周圍擴至 44px。

尺寸

<div class="flex flex-col items-center gap-lg">  <div class="snippet snippet-sm">    <span class="snippet-prompt" aria-hidden="true">$</span>    <code class="snippet-command" tabindex="0">npx master-ui add button</code>    <button type="button" class="btn btn-quiet btn-square" aria-label="Copy command">      <svg class="icon snippet-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M3 1.5H9A1.4999 1.4999 0 0 1 10.5 3V4.25H9.5V3A0.5002 0.5002 0 0 0 9 2.5H3A0.5002 0.5002 0 0 0 2.5 3V9A0.5002 0.5002 0 0 0 3 9.5H4.25V10.5H3A1.4999 1.4999 0 0 1 1.5 9V3A1.4999 1.4999 0 0 1 3 1.5Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><rect x="5.5" y="5.5" width="8.5" height="8.5" rx="1" />      </svg>      <svg class="icon snippet-check" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M3 8L6.3532 11.3532A0.2 0.2 0 0 0 6.6412 11.3479L13 4.5" />      </svg>    </button>    <output class="snippet-status"></output>  </div>  <div class="snippet">    <span class="snippet-prompt" aria-hidden="true">$</span>    <code class="snippet-command" tabindex="0">npx master-ui add button</code>    <button type="button" class="btn btn-quiet btn-square" aria-label="Copy command">      <svg class="icon snippet-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M3 1.5H9A1.4999 1.4999 0 0 1 10.5 3V4.25H9.5V3A0.5002 0.5002 0 0 0 9 2.5H3A0.5002 0.5002 0 0 0 2.5 3V9A0.5002 0.5002 0 0 0 3 9.5H4.25V10.5H3A1.4999 1.4999 0 0 1 1.5 9V3A1.4999 1.4999 0 0 1 3 1.5Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><rect x="5.5" y="5.5" width="8.5" height="8.5" rx="1" />      </svg>      <svg class="icon snippet-check" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M3 8L6.3532 11.3532A0.2 0.2 0 0 0 6.6412 11.3479L13 4.5" />      </svg>    </button>    <output class="snippet-status"></output>  </div>  <div class="flex flex-wrap items-center justify-center gap-sm">    <a class="btn btn-primary btn-lg" href="#">Get started</a>    <div class="snippet snippet-lg">      <span class="snippet-prompt" aria-hidden="true">$</span>      <code class="snippet-command" tabindex="0">npm install @master/ui</code>      <button type="button" class="btn btn-quiet btn-square" aria-label="Copy command">        <svg class="icon snippet-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">          <path d="M3 1.5H9A1.4999 1.4999 0 0 1 10.5 3V4.25H9.5V3A0.5002 0.5002 0 0 0 9 2.5H3A0.5002 0.5002 0 0 0 2.5 3V9A0.5002 0.5002 0 0 0 3 9.5H4.25V10.5H3A1.4999 1.4999 0 0 1 1.5 9V3A1.4999 1.4999 0 0 1 3 1.5Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><rect x="5.5" y="5.5" width="8.5" height="8.5" rx="1" />        </svg>        <svg class="icon snippet-check" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">          <path d="M3 8L6.3532 11.3532A0.2 0.2 0 0 0 6.6412 11.3479L13 4.5" />        </svg>      </button>      <output class="snippet-status"></output>    </div>  </div></div><script>document.querySelectorAll('.snippet').forEach(function (snippet) {var status = snippet.querySelector('.snippet-status')var timer = 0snippet.querySelector('.btn').addEventListener('click', function () {  var command = Array.prototype.find.call(snippet.querySelectorAll('.snippet-command'), function (line) {    return line.checkVisibility()  })  navigator.clipboard.writeText(command.textContent).then(function () {    status.textContent = 'Copied'    clearTimeout(timer)    timer = setTimeout(function () { status.textContent = '' }, 2000)  })})})</script>

#指令片段與程式碼的用途

指令片段用於可直接執行的單行指令。多行內容、檔案或供閱讀的輸出適合放在程式碼區塊中。句子中提到指令時,請使用行內程式碼。要標示使用者應按下的按鍵,請使用按鍵元件。

#無障礙

  • 終端機提示符號僅供裝飾,請加上 aria-hidden="true",讓螢幕閱讀器只朗讀指令。
  • 為複製按鈕加上 aria-label,例如「複製指令」。按鈕內的圖示使用 aria-hidden。
  • 在標記中讓 snippet-status 保持完全空白,連空白字元也不要放入。<output> 本身就是會在適當時機朗讀的即時區域,因此腳本填入的「已複製」會由螢幕閱讀器朗讀。
  • 為指令加上 tabindex="0",讓使用者能以鍵盤捲動超出可用寬度的指令。
  • 在強制色彩模式下,淡出效果會移除,凹槽會加上外框,提示符號則使用系統的灰色文字色。

#類別

類別說明
snippet高 38px 的凹槽,採用等寬字型,提示符號、指令和按鈕各占一欄
snippet-sm高度 32px 的列,字級為 12px。預設列高為 38px。搭配 snippet 使用
snippet-lg高度 44px 的列,字級為 14px,適用於頁首搭配 snippet 使用
snippet-prompt提示符號 $ 或 > 使用較低調的前景色,且無法選取。請加上 aria-hidden="true"。
snippet-command指令寫在 <code> 元素內,維持單行並可水平捲動。內容超出時,相應邊緣會淡出。請設定 tabindex="0"。搭配分段控制項時,依選項順序各寫一條指令,最多六條
snippet-icon按鈕內使用 icon 的複製圖示。狀態顯示指令已複製時,會由勾號取代
snippet-check按鈕內使用 icon 的勾號,放在複製圖示後方。複製完成後會取代複製圖示
snippet-status初始為空且不在畫面上顯示的 <output>,會向輔助技術播報腳本寫入的內容。寫入內容時,複製圖示會換成勾號,清空後則恢復原狀。

#自訂屬性

屬性預設值說明
--snippet-height2.375rem指令列的高度。按鈕比指令列矮 8px,上下各留 4px。設定於 snippet
--snippet-radiusvar(--radius-control)指令列套用圓角縮放前的圓角半徑。按鈕與選項向內縮 4px,因此各自的半徑比此值小 4px。設定於 snippet
--snippet-fade1.5rem長指令超出顯示範圍時,邊緣淡出的長度設定於 snippet

#原始碼

@master/ui/components/snippet.css
/* * Snippet: a command to copy, on one line: the prompt, the command and a button that copies it. * The line is a well, as a code block is: literal text is cut into the page, and the button that takes it is a * quiet control 4px in from the end, which rises as a sheet under the pointer as it does in a code panel. The * well is as tall as a button (32, 38 and 44px), so a snippet can stand in a row beside one, as an install line * stands beside the main action of a hero. * The prompt is a glyph in the mono face, quieter than the command; it cannot be selected and is not read aloud, * so selecting the line by hand takes the command alone. The command never wraps: a long one scrolls sideways * and fades at the edge where it goes on, read from its own scroll position. Without scroll-driven animations * it scrolls the same, with clean edges. * Copied is not a class: the script writes "Copied" into an <output> beside the button, which announces it, and * the stylesheet reads that the output is no longer empty and turns the copy icon into a check. Emptying it turns * it back. Without scripting the button is not drawn, and the command is still text to select. * With a segmented control in it, the snippet holds one command per package manager: the control gives up its * own well and lies along the top over a hairline, and the command whose place matches the checked option is * the one shown, for up to six, with no script. */@property --snippet-fade-start {  syntax: '<length>';  inherits: false;  initial-value: 0px;}@property --snippet-fade-end {  syntax: '<length>';  inherits: false;  initial-value: 0px;}@layer components.ui {  .snippet {    --snippet-height: 2.375rem;    --snippet-radius: var(--radius-control);    --snippet-padding-x: .875rem;    --snippet-font-size: .8125rem;    --snippet-fade: 1.5rem;    position: relative;    /* Three columns: the prompt, the command and the button. A row of options takes a row of its own above. */    display: grid;    grid-template-columns: auto minmax(0, 1fr) auto;    grid-auto-rows: minmax(var(--snippet-height), auto);    align-items: center;    min-width: 0;    margin: 0;    padding-block: 0;    padding-inline: var(--snippet-padding-x) 4px;    border-radius: calc(var(--snippet-radius) * var(--corner-scale));    corner-shape: var(--corner-shape);    background: var(--color-surface-inset);    color: var(--color-text-strong);    box-shadow: var(--shadow-pressed);    font: 400 var(--snippet-font-size)/1.5 var(--font-family-mono);    font-variant-ligatures: none;    /* A command is literal: no space the page adds between scripts and no trimmed punctuation in it. */    text-autospace: no-autospace;    text-spacing-trim: space-all;    &.snippet-sm {      --snippet-height: 2rem;      --snippet-radius: var(--radius-control-sm);      --snippet-padding-x: .75rem;      --snippet-font-size: .75rem;    }    &.snippet-lg {      --snippet-height: 2.75rem;      --snippet-radius: var(--radius-control-lg);      --snippet-padding-x: 1rem;      --snippet-font-size: .875rem;      .btn {        --icon-size: 1rem;      }    }    /* Focus on the command, which scrolls with the arrow keys, rings the whole line. */    &:has(.snippet-command:focus-visible) {      @apply --focus-ring;    }    /*     * The button in the well sits 4px in, so its corner is the well's corner minus that inset. It does not lift:     * it rises out of the well instead.     */    .btn {      --btn-height: calc(var(--snippet-height) - 8px);      --btn-radius: calc(var(--snippet-radius) - 4px / var(--corner-scale));      --btn-lift: 0px;      --icon-size: .875rem;      --icon-offset: 0px;      grid-column: 3;      min-height: var(--btn-height);      margin-inline-start: .375rem;      /* A square one stays square on touch, where a button alone would widen to 44px. */      &.btn-square {        min-width: var(--btn-height);      }    }    /*     * Package managers: the segmented control lies along the top of the well, over a hairline, and gives up its     * own well; its options rise out of the snippet's, 4px in, as tall and as round as the button below.     */    .segmented {      --segmented-inset: 4px;      --segmented-item-height: calc(var(--snippet-height) - 8px);      --segmented-item-radius: calc(var(--snippet-radius) - 4px / var(--corner-scale));      --segmented-font-size: .75rem;      display: flex;      grid-column: 1 / -1;      align-self: stretch;      gap: 2px;      max-width: none;      margin-inline: calc(-1 * var(--snippet-padding-x)) -4px;      border-radius: 0;      border-block-end: 1px solid var(--color-line-hair);      background: none;      box-shadow: none;    }    .segmented-item {      flex: none;      min-width: 0;      padding-inline: .625rem;    }    /* Each option shows the command in its place; the others step aside. */    &:has(.segmented) .snippet-command {      display: none;    }    &:has(.segmented-item:nth-child(1 of .segmented-item) .segmented-input:checked) .snippet-command:nth-child(1 of .snippet-command),    &:has(.segmented-item:nth-child(2 of .segmented-item) .segmented-input:checked) .snippet-command:nth-child(2 of .snippet-command),    &:has(.segmented-item:nth-child(3 of .segmented-item) .segmented-input:checked) .snippet-command:nth-child(3 of .snippet-command),    &:has(.segmented-item:nth-child(4 of .segmented-item) .segmented-input:checked) .snippet-command:nth-child(4 of .snippet-command),    &:has(.segmented-item:nth-child(5 of .segmented-item) .segmented-input:checked) .snippet-command:nth-child(5 of .snippet-command),    &:has(.segmented-item:nth-child(6 of .segmented-item) .segmented-input:checked) .snippet-command:nth-child(6 of .snippet-command) {      display: block;    }    /* Copying needs a script; without one the button would do nothing, so it is not drawn. */    @media (scripting: none) {      .btn {        display: none;      }    }    @media (forced-colors: active) {      outline: 1px solid CanvasText;      outline-offset: -1px;      /* The control gave up its own well, so it gives up the outline that draws one too; the hairline stays. */      .segmented {        outline: none;      }      &:has(.snippet-command:focus-visible) {        outline: 2px solid Highlight;        outline-offset: 2px;      }    }  }  /* The prompt: a glyph such as $ or >, quieter than the command. Mark it aria-hidden. */  .snippet-prompt {    grid-column: 1;    margin: 0;    margin-inline-end: 1ch;    color: var(--color-text-muted);    font: inherit;    user-select: none;    -webkit-user-select: none;    @media (forced-colors: active) {      color: GrayText;    }  }  /*   * The command: one line that scrolls sideways and never wraps, with no scrollbar. Give it tabindex="0" so the   * keys can scroll it. Where it goes on past an edge, that edge fades.   */  .snippet-command {    display: block;    grid-column: 2;    min-width: 0;    margin: 0;    padding: 0;    overflow: auto hidden;    background: none;    color: inherit;    font: inherit;    white-space: pre;    outline: none;    scrollbar-width: none;    overscroll-behavior-inline: contain;    &::-webkit-scrollbar {      display: none;    }    @supports (animation-timeline: scroll()) {      /* From the start edge to the end edge: right to left, the start edge is on the right. */      --snippet-run: to right;      mask-image: linear-gradient(var(--snippet-run), transparent, black var(--snippet-fade-start), black calc(100% - var(--snippet-fade-end)), transparent);      /* Longhands: tools that fold the timeline into the shorthand write a value no browser reads. */      animation-name: snippet-fade-start, snippet-fade-end;      animation-timing-function: linear;      animation-fill-mode: both;      animation-timeline: scroll(self inline), scroll(self inline);      animation-range: 0 var(--snippet-fade), calc(100% - var(--snippet-fade)) 100%;      &:dir(rtl) {        --snippet-run: to left;      }    }    @media (forced-colors: active) {      mask-image: none;    }  }  /*   * The copy icon, and the check that takes its place once copied, in the strong ink. Both sit in the button, one   * over the other; the swap is a quick cross-fade, and with motion the check grows into place as the icon shrinks.   */  .snippet-icon, .snippet-check {    transition-property: opacity, scale;    transition-duration: var(--duration-quick);    transition-timing-function: var(--easing-glide);  }  .snippet-check {    position: absolute;    inset: 0;    margin: auto;    color: var(--color-text-strong);    opacity: 0;  }  .snippet:has(.snippet-status:not(:empty)) {    .snippet-icon {      opacity: 0;    }    .snippet-check {      opacity: 1;    }  }  @media (prefers-reduced-motion: no-preference) {    .snippet-check {      scale: .6;    }    .snippet:has(.snippet-status:not(:empty)) {      .snippet-icon {        scale: .6;      }      .snippet-check {        scale: 1;      }    }  }  /* An <output> the script writes "Copied" into: announced, never seen. The icon says it to the eye. */  .snippet-status {    position: absolute;    width: 1px;    height: 1px;    margin: 0;    overflow: hidden;    clip-path: inset(50%);    white-space: nowrap;  }}@keyframes snippet-fade-start {  from {    --snippet-fade-start: 0px;  }  to {    --snippet-fade-start: var(--snippet-fade);  }}@keyframes snippet-fade-end {  from {    --snippet-fade-end: var(--snippet-fade);  }  to {    --snippet-fade-end: 0px;  }}