ナビゲーション

v2.1.0
タイポグラフィ

スニペット

コピー用の1行のコマンドを、プロンプトとコピーボタン付きで表示します。

このページの内容

スニペットは、ターミナルで実行する1行のコマンドを、プロンプトとコピーボタン付きで表示します。コードブロックと同じように等幅フォントで表示するくぼんだ面で、ボタンと同じ高さなので横に並べられます。プロンプトは選択できず、コマンドは折り返しません。コピーボタンは終端から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>
コマンドをコピーすると、アイコンが2秒間チェックマークに変わります。

#コマンド行

snippetは、プロンプト、コマンド、コピーボタンを3列に並べます。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)で表します。この要素は画面には表示されません。スクリプトが「コピーしました」と書き込むとスクリーンリーダーが読み上げ、2秒後にスクリプトが内容を消去します。内容がある間は、スタイルシートがコピーアイコンをチェックマークに切り替え、画面上でもコピーの完了を伝えます。

プレビューのスクリプトは、表示中のコマンドを取得してクリップボードに書き込み、ステータスにメッセージを入れてから消去します。クリップボードを利用できるのは、HTTPSまたはlocalhostで配信されるページに限られます。スクリプトが無効な場合はボタンが表示されず、コマンドを手動で選択してコピーできます。

#パッケージマネージャー

同じ操作を行うコマンドをnpm、pnpm、bun、yarnごとに用意するには、ネイティブのラジオボタンで構成したセグメントコントロールをスニペットの先頭に置き、各選択肢に対応するsnippet-commandを、選択肢と同じ順序で1つずつ記述します。コントロール自体の背景はなくなり、スニペット上部の細い罫線の上に並びます。選択された項目は一段浮いた面として表示され、選択を変えるとその面が次の項目へ滑らかに移動します。選択された項目と同じ順番にあるコマンドが表示されます。スクリプトなしで最大6項目に対応します。

パッケージマネージャー

<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>

#スニペットとコードの使い分け

スニペットは、実行する1行のコマンドに使います。複数行のコード、ファイルの内容、出力結果を読ませる場合はコードブロック、文中でコマンドに言及する場合はインラインのコードを使います。押すキーにはキーボード入力を使います。

#アクセシビリティ

  • 装飾用のプロンプトにはaria-hidden="true"を指定し、コマンドだけが読み上げられるようにします。
  • コピーボタンには「コマンドをコピー」などのaria-labelを指定します。アイコンにはaria-hiddenを指定します。
  • マークアップではsnippet-statusを空にし、空白文字も入れないでください。スクリプトが書き込んだ「コピーしました」がここから読み上げられます。<output>はそれ自体が優先度 polite のライブリージョンです。
  • コマンドにtabindex="0"を指定し、行に収まらない場合にキーボードでスクロールできるようにします。
  • 強制カラーモードでは、フェードがなくなり、コマンド欄に輪郭が付き、プロンプトにはシステムのグレーのテキスト色が適用されます。

#クラス

クラス説明
snippet高さ 38px のくぼみ。等幅書体を使い、プロンプト、コマンド、ボタンを 3 列に配置
snippet-sm高さ 32px、文字サイズ 12px の行です。既定の高さは 38px です。snippet と併用します
snippet-lgページ上部向けの、高さ 44px、文字サイズ 14px の行です。snippet と併用します
snippet-promptプロンプト記号($ または >)は控えめな文字色で表示され、選択できません。aria-hidden="true" を指定します。
snippet-command<code> に置くコマンド。折り返さない 1 行で横スクロールでき、続きがある側の端でフェードします。tabindex="0" を付けます。セグメントコントロールと併用する場合は、各選択肢に 1 つずつ、同じ順序で最大 6 つ記述します。
snippet-iconボタン内のコピーアイコン。icon を指定します。ステータスがコマンドのコピー完了を示すと非表示になります。
snippet-checkボタン内でコピーアイコンの後に置くチェックマーク。icon を付けます。コピー後はコピーアイコンに代わって表示されます。
snippet-status画面には表示されない空の <output> です。スクリプトが書き込んだ内容を読み上げます。書き込むとコピーアイコンがチェックマークに変わり、空にすると元に戻ります。

#カスタムプロパティ

プロパティ既定値説明
--snippet-height2.375rem行の高さです。ボタンは行より 8px 低く、上下に 4px ずつ内側に配置されます。指定先:snippet
--snippet-radiusvar(--radius-control)角のスケールを適用する前の、くぼみの角の半径です。ボタンと選択肢の半径は、内側に寄せる分だけ 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;  }}