탐색

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>
명령어를 복사하면 아이콘이 2초 동안 체크 표시로 바뀝니다.

#명령어 줄 구성

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)가 있습니다. 스크립트가 여기에 ‘복사됨’을 쓰면 스크린 리더가 이를 읽어 주고, 2초 뒤 스크립트가 내용을 비웁니다. 내용이 있는 동안 스타일시트가 복사 아이콘을 체크 표시로 바꾸므로 화면에서도 같은 상태를 확인할 수 있습니다.

미리보기의 스크립트는 화면에 표시된 명령어를 찾아 클립보드에 쓴 뒤 상태 메시지를 채웠다가 비웁니다. 이 스크립트가 전체 구현입니다. 클립보드 기능은 HTTPS로 제공되거나 localhost에서 제공되는 페이지에서만 사용할 수 있습니다. 스크립트가 비활성화되어 있으면 버튼이 표시되지 않으며, 명령어는 텍스트로 남아 직접 선택해 복사할 수 있습니다.

#패키지 관리자

같은 작업을 실행하는 명령어를 npm, pnpm, bun, yarn별로 제공하려면 네이티브 라디오 버튼으로 구성한 세그먼트 컨트롤을 스니펫 맨 앞에 배치하고, 각 옵션에 해당하는 snippet-command를 옵션과 같은 순서로 작성하세요. 컨트롤 자체의 오목한 영역은 사라지고, 컨트롤은 스니펫 상단의 아주 얇은 구분선 위에 놓입니다. 선택한 옵션은 한 층 위에 놓인 표면으로 표시되며, 다른 옵션을 선택하면 그 표면이 새 위치로 부드럽게 이동합니다. 최대 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>

#스니펫과 코드의 용도

실행할 한 줄짜리 명령어에는 스니펫을 사용합니다. 여러 줄이나 읽어야 할 파일 또는 출력에는 코드 블록을 사용하고, 문장 속에서 언급하는 명령어에는 인라인 코드를 사용합니다. 눌러야 할 키는 kbd로 표시합니다.

#접근성

  • 프롬프트는 장식이므로 명령어 줄에서 스크린 리더가 명령어만 읽도록 프롬프트에 aria-hidden="true"를 지정하세요.
  • 복사 버튼에 ‘명령어 복사’와 같은 aria-label 값을 지정하세요. 버튼 아이콘에는 aria-hidden 속성이 지정되어 있습니다.
  • 마크업에서 snippet-status를 비워 두고 내부에 공백도 넣지 마세요. 스크립트가 여기에 ‘복사됨’을 쓰면 스크린 리더가 이를 읽어 줍니다. <output> 자체가 현재 읽기를 방해하지 않는 라이브 영역입니다.
  • 한 줄의 표시 영역보다 긴 명령어를 키보드로 스크롤할 수 있도록 명령어에 tabindex="0"를 지정하세요.
  • 강제 색상 모드에서는 흐림 효과가 사라지고, 오목한 영역에 윤곽선이 표시되며, 프롬프트에는 시스템의 회색 텍스트 색상이 적용됩니다.

#클래스

클래스설명
snippet높이 38px의 오목한 영역입니다. 고정폭 글꼴을 사용하며 프롬프트, 명령, 버튼을 세 열에 배치합니다.
snippet-sm12px 글자를 쓰는 32px 높이의 줄입니다. 기본 높이는 38px입니다.적용할 클래스는 snippet입니다
snippet-lg페이지 상단에 쓰는 44px 높이의 줄로, 글자 크기는 14px입니다.적용할 클래스는 snippet입니다
snippet-prompt프롬프트 기호($ 또는 >)는 차분한 전경색으로 표시하며 텍스트로 선택할 수 없습니다. aria-hidden="true"를 지정하세요.
snippet-command명령을 <code> 요소에 넣습니다. 줄바꿈 없이 한 줄로 표시되며, 가로로 스크롤할 수 있고 내용이 이어지는 가장자리에서 서서히 흐려집니다. tabindex="0"을 지정하세요. 세그먼트 컨트롤과 함께 쓸 때는 옵션과 같은 순서로 옵션당 하나씩, 최대 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;  }}