탐색

v2.1.0
피드백

시머

작업이 진행 중임을 알리는 텍스트 위로 빛이 지나갑니다.

이 페이지의 내용

시머는 ‘생각 중’, ‘파일 14개 검색 중’, ‘배포 중’처럼 작업이 진행 중임을 알리는 한 줄의 텍스트입니다. 글자는 평소에 주변 텍스트 색의 절반을 조금 넘는 강도로 표시됩니다. 같은 색을 최대 강도로 표시하는 띠가 글자 위를 지나가면 띠가 닿는 부분만 밝아지고 색조는 그대로 유지됩니다. 텍스트를 담는 요소에 shimmer를 적용하세요.

시머

<p class="shimmer text-sm" role="status">Thinking…</p><p class="shimmer text-sm" role="status">Searching 14 files for “corner-shape”</p>
<>  <p className="shimmer text-sm" role="status">Thinking…</p>  <p className="shimmer text-sm" role="status">Searching 14 files for “corner-shape”</p></>
<p class="shimmer text-sm" role="status">Thinking…</p><p class="shimmer text-sm" role="status">Searching 14 files for “corner-shape”</p>
<template>  <p class="shimmer text-sm" role="status">Thinking…</p>  <p class="shimmer text-sm" role="status">Searching 14 files for “corner-shape”</p></template>

#자리 표시자 대신 상태 텍스트

스켈레톤은 형태는 알지만 어떤 문구가 들어갈지는 아직 모르는 콘텐츠의 자리를 채웁니다. 스피너는 어떤 작업이 진행 중이라는 사실만 알립니다. 시머는 그 중간에 해당합니다. 어떤 작업이 진행 중인지 텍스트로 설명할 수 있을 때, 그 텍스트 자체가 상태를 나타냅니다.

빛은 글자 모양으로 잘라낸 배경으로 구현합니다. 글자는 텍스트로 유지되므로 선택, 복사, 번역, 음성 읽기가 가능합니다. 상자는 텍스트 너비에 맞춰 줄어들므로 빛은 글자 위로만 지나갑니다.

#다른 컴포넌트와 함께 사용

이 클래스는 글자 크기와 굵기를 지정하지 않으므로 시머는 배치된 곳의 글자 스타일을 따릅니다. 아직 도착하지 않은 대화 응답, 진행 중인 단계, 로딩 중인 페이지의 제목에 사용할 수 있습니다.

대화와 목록의 시머

<div class="flex flex-col">  <div class="message message-sent">    <div class="message-bubble">What changed in the last release?</div>  </div>  <div class="message">    <div class="message-bubble">      <span class="shimmer" role="status">Reading the changelog…</span>    </div>  </div></div><ol class="steps steps-vertical">  <li class="steps-item">    <div class="steps-body">      <p class="steps-title">Install dependencies</p>    </div>  </li>  <li class="steps-item" aria-current="step">    <div class="steps-body">      <p class="steps-title shimmer">Building 212 pages</p>    </div>  </li>  <li class="steps-item">    <div class="steps-body">      <p class="steps-title">Deploy</p>    </div>  </li></ol>
<>  <div className="flex flex-col">    <div className="message message-sent">      <div className="message-bubble">What changed in the last release?</div>    </div>    <div className="message">      <div className="message-bubble">        <span className="shimmer" role="status">Reading the changelog…</span>      </div>    </div>  </div>  <ol className="steps steps-vertical">    <li className="steps-item">      <div className="steps-body">        <p className="steps-title">Install dependencies</p>      </div>    </li>    <li className="steps-item" aria-current="step">      <div className="steps-body">        <p className="steps-title shimmer">Building 212 pages</p>      </div>    </li>    <li className="steps-item">      <div className="steps-body">        <p className="steps-title">Deploy</p>      </div>    </li>  </ol></>
<div class="flex flex-col">  <div class="message message-sent">    <div class="message-bubble">What changed in the last release?</div>  </div>  <div class="message">    <div class="message-bubble">      <span class="shimmer" role="status">Reading the changelog…</span>    </div>  </div></div><ol class="steps steps-vertical">  <li class="steps-item">    <div class="steps-body">      <p class="steps-title">Install dependencies</p>    </div>  </li>  <li class="steps-item" aria-current="step">    <div class="steps-body">      <p class="steps-title shimmer">Building 212 pages</p>    </div>  </li>  <li class="steps-item">    <div class="steps-body">      <p class="steps-title">Deploy</p>    </div>  </li></ol>
<template>  <div class="flex flex-col">    <div class="message message-sent">      <div class="message-bubble">What changed in the last release?</div>    </div>    <div class="message">      <div class="message-bubble">        <span class="shimmer" role="status">Reading the changelog…</span>      </div>    </div>  </div>  <ol class="steps steps-vertical">    <li class="steps-item">      <div class="steps-body">        <p class="steps-title">Install dependencies</p>      </div>    </li>    <li class="steps-item" aria-current="step">      <div class="steps-body">        <p class="steps-title shimmer">Building 212 pages</p>      </div>    </li>    <li class="steps-item">      <div class="steps-body">        <p class="steps-title">Deploy</p>      </div>    </li>  </ol></template>

#효과 조정

--shimmer-duration은 띠가 한 번 지나가는 데 걸리는 시간입니다. 기본값은 2초이며, 긴 문장에는 3초를 줄 수 있습니다. --shimmer-color는 띠가 지나가지 않을 때의 글자색이고, --shimmer-light는 띠의 색입니다. 두 색 모두 현재 글자색을 바탕으로 혼합하므로 페이지, 카드, 보낸 메시지 안에서 각각의 글자색에 맞게 표시됩니다.

prefers-reduced-motion: reduce가 적용되면 띠가 사라지고 텍스트는 평소의 옅은 색으로 표시됩니다. 텍스트는 계속해서 진행 중인 작업을 알립니다.

#접근성

  • 사용자가 페이지를 보고 있는 동안 텍스트가 나타나거나 바뀌면 스크린 리더가 이를 읽어 주도록 해당 줄에 role="status"를 지정하세요. 작업당 상태 영역은 하나면 충분합니다.
  • 결과가 도착하면 시머를 결과로 교체하세요. 이미 표시된 콘텐츠 옆에 시머를 계속 실행해 두지 마세요.
  • 시각 효과는 장식용입니다. 상태 정보는 모두 텍스트로 전달합니다.

#클래스

클래스설명
shimmer옅은 글자색 위로 빛이 띠처럼 지나갑니다. 텍스트를 담는 요소에 적용합니다.

#사용자 지정 속성

속성기본값설명
--shimmer-duration2s빛의 띠가 텍스트 위를 한 번 지나가는 데 걸리는 시간
--shimmer-colorcolor-mix(in oklab, currentColor 56%, transparent)기본 상태의 텍스트 색상
--shimmer-lightcurrentColor빛의 띠 색상

#소스

@master/ui/components/shimmer.css
/* * Shimmer: a line of words that says work is under way, with a band of light passing over the letters. * The words rest at a little over half the ink of the text around them and the band is that ink in full, so * the line brightens where the light is, never changes hue and reads on any surface it is put on. It is drawn * as a background clipped to the text, which leaves the words selectable and real. * With reduced motion the line rests in its quieter ink, --shimmer-color, without the band; in forced colors * it is plain text. */@layer components.ui {  .shimmer {    --shimmer-color: color-mix(in oklab, currentColor 56%, transparent);    --shimmer-light: currentColor;    --shimmer-duration: 2s;    /* The box is as wide as the words, so the light crosses the words and not the room beside them. */    width: fit-content;    max-width: 100%;    background:      linear-gradient(100deg, transparent 38%, var(--shimmer-light) 50%, transparent 62%) 150% 0 / 300% 100% no-repeat,      linear-gradient(var(--shimmer-color), var(--shimmer-color));    /* The prefixed clip first: an engine that knows only it would otherwise clear the fill and lose the words. */    -webkit-background-clip: text;    background-clip: text;    /* The fill is cleared, not the color: the ink above is still the color of the text around the line. */    -webkit-text-fill-color: transparent;    /* Linear: the light crosses at one speed and the loop has no seam to rest at. */    animation: shimmer-sweep var(--shimmer-duration) linear infinite;    /* The light crosses the words the way they are read: from the right where they run from the right. */    &:dir(rtl) {      animation-direction: reverse;    }    @media (prefers-reduced-motion: reduce) {      background: none;      -webkit-text-fill-color: var(--shimmer-color);      animation: none;    }    @media (forced-colors: active) {      background: none;      -webkit-text-fill-color: currentColor;      animation: none;    }  }}@keyframes shimmer-sweep {  to {    background-position: -50% 0, 0 0;  }}