탐색

v2.1.0
피드백

스켈레톤

로딩 중인 콘텐츠의 형태를 미리 표시해, 콘텐츠가 나타날 때 페이지가 흔들리지 않게 합니다.

이 페이지의 내용

스켈레톤은 로딩 중인 콘텐츠가 표시될 형태로 자리를 채워, 콘텐츠가 나타날 때 페이지 레이아웃이 갑자기 바뀌지 않게 합니다. 칩과 같은 색조의 블록 위로 은은한 빛의 띠가 지나갑니다. 브라우저가 sibling-index()를 지원하면 한 블록 안의 스켈레톤이 차례로 움직이기 시작해 빛이 블록 전체를 한 번에 훑고 내려가는 것처럼 보입니다. 각 스켈레톤의 크기를 그 스켈레톤이 대신하는 콘텐츠의 크기에 맞추세요. 이미 표시된 콘텐츠를 다시 불러오는 중이라면 처리 중 상태를 사용하세요.

스켈레톤

<section class="flex items-center gap-sm" aria-busy="true" aria-label="Loading member">  <span class="skeleton skeleton-circle w(40)" aria-hidden="true"></span>  <div class="flex flex-col w-full text-sm" aria-hidden="true">    <span class="skeleton skeleton-text max-w(160)"></span>    <span class="skeleton skeleton-text max-w(320)"></span>  </div></section>
<section className="flex items-center gap-sm" aria-busy="true" aria-label="Loading member">  <span className="skeleton skeleton-circle w(40)" aria-hidden="true"></span>  <div className="flex flex-col w-full text-sm" aria-hidden="true">    <span className="skeleton skeleton-text max-w(160)"></span>    <span className="skeleton skeleton-text max-w(320)"></span>  </div></section>
<section class="flex items-center gap-sm" aria-busy="true" aria-label="Loading member">  <span class="skeleton skeleton-circle w(40)" aria-hidden="true"></span>  <div class="flex flex-col w-full text-sm" aria-hidden="true">    <span class="skeleton skeleton-text max-w(160)"></span>    <span class="skeleton skeleton-text max-w(320)"></span>  </div></section>
<template>  <section class="flex items-center gap-sm" aria-busy="true" aria-label="Loading member">    <span class="skeleton skeleton-circle w(40)" aria-hidden="true"></span>    <div class="flex flex-col w-full text-sm" aria-hidden="true">      <span class="skeleton skeleton-text max-w(160)"></span>      <span class="skeleton skeleton-text max-w(320)"></span>    </div>  </section></template>

#형태

  • skeleton만 사용하면 블록으로 표시됩니다. 이미지, 차트 또는 카드의 높이에 맞추세요.
  • skeleton-text는 텍스트 한 줄을 대신합니다. 글자와 같은 높이로 해당 줄의 세로 중앙에 놓이므로, 실제 텍스트가 표시될 때도 같은 기준선 그리드에 맞춰집니다. 주변 텍스트의 글자 크기와 줄 높이를 따릅니다.
  • skeleton-circle은 아바타나 아이콘을 대신합니다. 너비를 지정하면 높이도 그에 맞춰 정해집니다.

로딩 중인 카드

<article class="card max-w(320) mx-auto" aria-busy="true" aria-label="Loading project">  <span class="skeleton card-media" aria-hidden="true"></span>  <div class="flex flex-col" aria-hidden="true">    <span class="skeleton skeleton-text max-w(160)"></span>    <span class="skeleton skeleton-text"></span>    <span class="skeleton skeleton-text max-w(240)"></span>  </div></article>
<article className="card max-w(320) mx-auto" aria-busy="true" aria-label="Loading project">  <span className="skeleton card-media" aria-hidden="true"></span>  <div className="flex flex-col" aria-hidden="true">    <span className="skeleton skeleton-text max-w(160)"></span>    <span className="skeleton skeleton-text"></span>    <span className="skeleton skeleton-text max-w(240)"></span>  </div></article>
<article class="card max-w(320) mx-auto" aria-busy="true" aria-label="Loading project">  <span class="skeleton card-media" aria-hidden="true"></span>  <div class="flex flex-col" aria-hidden="true">    <span class="skeleton skeleton-text max-w(160)"></span>    <span class="skeleton skeleton-text"></span>    <span class="skeleton skeleton-text max-w(240)"></span>  </div></article>
<template>  <article class="card max-w(320) mx-auto" aria-busy="true" aria-label="Loading project">    <span class="skeleton card-media" aria-hidden="true"></span>    <div class="flex flex-col" aria-hidden="true">      <span class="skeleton skeleton-text max-w(160)"></span>      <span class="skeleton skeleton-text"></span>      <span class="skeleton skeleton-text max-w(240)"></span>    </div>  </article></template>

#접근성

  • aria-hidden="true"로 스켈레톤을 보조 기술에서 숨기고, 스켈레톤이 채우는 영역에는 aria-busy="true"와 함께 어떤 콘텐츠를 불러오는지 알리는 레이블을 지정하세요.
  • 동작 줄이기가 활성화되면 빛의 띠가 움직이지 않습니다. 이때는 형태만으로 콘텐츠가 로딩 중임을 나타냅니다.
  • 사용자가 대기 시간을 체감할 가능성이 있을 때만 스켈레톤을 표시하세요. 대기 시간이 짧으면 아무것도 표시하지 마세요. 버튼에는 aria-busy와 스피너를 사용하세요.

#클래스

클래스설명
skeleton자리 표시자 블록입니다. 대신 표시할 이미지, 차트 또는 카드와 높이를 같게 지정하세요.
skeleton-text텍스트 한 줄을 대신하는 자리 표시자입니다. 높이는 글자 높이와 같으며, 원래 텍스트가 놓일 줄의 세로 중앙에 배치합니다.적용할 클래스는 skeleton입니다
skeleton-circle너비로 크기를 정하는 아바타 또는 아이콘용 원적용할 클래스는 skeleton입니다

#소스

@master/ui/components/skeleton.css
/* * Skeleton: the shape of content that is on its way. * A chip-toned block that a soft band of light crosses; with reduced motion it rests. * Hide it from assistive technology and mark the loading region with aria-busy. */@layer components.ui {  .skeleton {    display: block;    min-height: .75rem;    border-radius: calc(var(--radius-chip) * var(--corner-scale));    corner-shape: var(--corner-shape);    background:      linear-gradient(100deg, transparent 35%, var(--color-sheen) 50%, transparent 65%) 150% 0 / 300% 100% no-repeat,      var(--color-surface-chip);    color: transparent;    user-select: none;    -webkit-user-select: none;    pointer-events: none;    animation: skeleton-sweep 1.8s var(--easing-smooth) infinite;    /* The band crosses the way the words it stands for are read: from the right where they run from the right. */    &:dir(rtl) {      animation-direction: reverse;    }    /* One line of text: the block is as tall as the letters, centered in the line it stands for. */    &.skeleton-text {      height: .75em;      min-height: 0;      margin-block: calc((1lh - .75em) / 2);      border-radius: calc((var(--radius-chip) - 2px) * var(--corner-scale));    }    &.skeleton-circle {      aspect-ratio: 1;      border-radius: 999px;      corner-shape: round;    }    /* Lines in one block start one after another, so the band of light runs down the block as a single pass. */    @supports (width: calc(sibling-index() * 1px)) {      animation-delay: calc((sibling-index() - 1) * 90ms);    }    @media (prefers-reduced-motion: reduce) {      animation: none;    }    @media (forced-colors: active) {      outline: 1px solid GrayText;      outline-offset: -1px;    }  }}@keyframes skeleton-sweep {  to {    background-position: -50% 0, 0 0;  }}