탐색

v2.1.0
피드백

처리 중

콘텐츠를 다시 불러오는 영역에 덮개와 스피너를 표시합니다.

이 페이지의 내용

처리 중 상태는 필터가 바뀐 카드, 새 페이지를 불러오는 표, 저장 중인 양식처럼 콘텐츠를 다시 가져오고 있는 영역에 표시합니다. 영역에 busy 클래스를 적용하고 작업이 진행되는 동안 aria-busy="true"를 설정하세요. 영역의 표면색을 사용한 덮개가 기존 콘텐츠의 강조를 낮추고, 가운데에서는 스피너가 회전합니다. 기존 콘텐츠가 제자리를 유지하므로 새 콘텐츠가 표시될 때 레이아웃이 갑자기 움직이지 않습니다.

처리 중

<article class="card busy w-full max-w(320)" id="revenue" aria-label="Revenue">  <header class="card-header">    <h3 class="card-title">Revenue</h3>    <p class="card-description">$48,200 this month, up 12% on October.</p>  </header>  <footer class="card-footer">    <button class="btn btn-sm" type="button" id="revenue-refresh">Refresh</button>  </footer></article><script>var card = document.getElementById('revenue')document.getElementById('revenue-refresh').addEventListener('click', function () {  card.setAttribute('aria-busy', 'true')  card.inert = true  setTimeout(function () {    card.removeAttribute('aria-busy')    card.inert = false  }, 1800)})</script>
새로 고침을 누르면 카드가 2초 동안 처리 중 상태가 됩니다.

#하나의 상태 속성

클래스만 적용하면 화면에 아무것도 표시되지 않습니다. 같은 요소에 지정한 aria-busy="true"가 처리 중 상태를 결정합니다. 스크린 리더에 전달되는 상태와 스타일시트가 참조하는 상태가 같으므로 두 상태가 어긋나지 않습니다. 작업이 끝나면 속성을 제거하거나 값을 false로 설정하세요.

덮개는 160ms 후 서서히 나타납니다. 작업이 바로 끝나면 덮개가 깜빡이지 않고, 이미 표시된 콘텐츠를 기다리라는 안내도 나오지 않습니다.

처리 중 상태

<article class="card busy w-full max-w(320)" aria-busy="true" aria-label="Revenue" inert>  <header class="card-header">    <h3 class="card-title">Revenue</h3>    <p class="card-description">$48,200 this month, up 12% on October.</p>  </header>  <footer class="card-footer"><button class="btn btn-sm" type="button">Refresh</button></footer></article>
<article className="card busy w-full max-w(320)" aria-busy="true" aria-label="Revenue" inert>  <header className="card-header">    <h3 className="card-title">Revenue</h3>    <p className="card-description">$48,200 this month, up 12% on October.</p>  </header>  <footer className="card-footer">    <button className="btn btn-sm" type="button">Refresh</button>  </footer></article>
<article class="card busy w-full max-w(320)" aria-busy="true" aria-label="Revenue" inert>  <header class="card-header">    <h3 class="card-title">Revenue</h3>    <p class="card-description">$48,200 this month, up 12% on October.</p>  </header>  <footer class="card-footer"><button class="btn btn-sm" type="button">Refresh</button></footer></article>
<template>  <article class="card busy w-full max-w(320)" aria-busy="true" aria-label="Revenue" inert>    <header class="card-header">      <h3 class="card-title">Revenue</h3>      <p class="card-description">$48,200 this month, up 12% on October.</p>    </header>    <footer class="card-footer"><button class="btn btn-sm" type="button">Refresh</button></footer>  </article></template>

#덮개

덮개 색은 시트, 카드, 대화 상자가 제공하는 --surface-color를 바탕으로 혼합합니다. 따라서 카드에는 회색 대신 카드 자체의 표면색이 적용됩니다. 자체 표면이 없는 영역에서는 페이지의 캔버스 색을 사용합니다. 덮개는 영역의 모서리 모양을 따릅니다. 스피너 바로 뒤는 불투명하게 가리고 주변은 더 투명하게 처리하므로 스피너의 링이 글자와 겹쳐 보이지 않습니다.

덮개는 아래 요소에 대한 포인터 입력을 막습니다. 키보드 입력을 막으려면 첫 번째 예제처럼 처리 중인 동안 inert 속성을 추가하고 작업이 끝나면 제거하세요.

--busy-size는 스피너의 지름을 설정합니다. 기본값은 20px입니다.

#처리 중 상태와 스켈레톤

처리 중 상태는 이미 표시된 콘텐츠를 교체할 때 사용합니다. 처음 불러오는 콘텐츠는 스켈레톤으로 형태를 표시하세요. 개별 컨트롤에서 대기가 필요하면 해당 컨트롤 안에 스피너를 표시하고, 버튼에는 자체 aria-busy 상태를 사용하세요.

#접근성

  • aria-busy="true"는 영역이 업데이트 중임을 보조 기술에 알립니다. 보조 기술은 이 속성이 제거될 때까지 영역 안의 변경 사항을 읽지 않을 수 있습니다.
  • 이 속성은 작업이 시작됐다는 안내를 제공하지 않습니다. 처리 중인 영역 바깥의 라이브 영역이나 작업을 시작한 컨트롤에서 텍스트로 안내하세요.
  • 처리 중에는 영역을 inert 상태로 설정해 덮개 아래의 컨트롤에 포커스를 두거나 컨트롤을 누를 수 없게 하세요.
  • 사용자가 동작 줄이기를 설정하면 스피너가 더 느리게 회전합니다. 강제 색상 모드에서는 덮개에 캔버스 색을 사용합니다.

#클래스

클래스설명
busy영역 자체에 aria-busy="true"가 설정된 동안 표면과 같은 색의 덮개를 씌워 콘텐츠가 덜 두드러지게 하고, 가운데에서 스피너를 회전시킵니다. 덮개는 영역의 모서리 모양을 따르며 160ms 후에 나타납니다.

#사용자 지정 속성

속성기본값설명
--busy-size1.25rem스피너 지름

#소스 코드

@master/ui/components/busy.css
/* * Busy: a region whose content is being fetched again. * While the region carries aria-busy="true", a veil in the color of the surface it lies on steps its content * back and a spinner turns in the middle, where the veil is whole. What was there stays where it was, so * nothing jumps when the new content arrives; for content that has never loaded, use a skeleton instead. * The veil waits 160ms before it shows: work that ends at once never flashes. It takes the region's own * corner and keeps the pointer off what is under it; add the inert attribute to keep the keyboard out too. */@layer components.ui {  .busy {    --busy-size: 1.25rem;    --busy-width: max(1.5px, calc(var(--busy-size) / 9));    --busy-surface: var(--surface-color, var(--color-surface-base));    position: relative;    &[aria-busy="true"] {      /*       * The veil and the spinner stack inside the region only: without its own stacking context their z-index       * would lift them over a sticky header of the page that scrolls over the region.       */      isolation: isolate;      /* The veil. */      &::before {        content: '';        position: absolute;        z-index: 2;        inset: 0;        border-radius: inherit;        corner-shape: inherit;        /* The veil is whole behind the spinner and thins out around it, so the ring never stands on a word. */        background:          radial-gradient(circle at center, var(--busy-surface) calc(var(--busy-size) * .7), transparent calc(var(--busy-size) * 1.7)),          color-mix(in oklab, var(--busy-surface) 62%, transparent);        cursor: progress;        animation: busy-arrive var(--duration-base) var(--easing-glide) 160ms both;      }      /* The spinner: the same fine ring as the spinner component, in the strong ink. */      &::after {        content: '';        position: absolute;        z-index: 3;        inset: 0;        width: var(--busy-size);        height: var(--busy-size);        margin: auto;        border-radius: 999px;        background: conic-gradient(from 90deg, color-mix(in oklab, var(--color-text-strong) 12%, transparent) 0 18%, var(--color-text-strong));        mask: radial-gradient(farthest-side, transparent calc(100% - var(--busy-width) - .5px), black calc(100% - var(--busy-width)), black calc(100% - .5px), transparent);        pointer-events: none;        animation: busy-arrive var(--duration-base) var(--easing-glide) 160ms both, busy-rotate .72s linear infinite;      }      @media (prefers-reduced-motion: reduce) {        &::after {          animation-duration: var(--duration-base), 1.8s;        }      }      /* The veil keeps its 160ms wait, as the spinner does: it fades in to its own opacity. */      @media (forced-colors: active) {        &::before {          background: Canvas;          opacity: .7;        }        &::after {          background: conic-gradient(from 90deg, GrayText 0 18%, CanvasText);          forced-color-adjust: none;        }      }    }  }}@keyframes busy-arrive {  from {    opacity: 0;  }}@keyframes busy-rotate {  to {    rotate: 360deg;  }}