Skeleton

콘텐츠가 로드되는 동안 펄스 효과를 보여주는 손그림 스타일의 로딩 플레이스홀더입니다.

개요

Skeleton은 콘텐츠가 로드되는 동안 그 자리를 대신하는 플레이스홀더로, 레이아웃을 유지하고 올 콘텐츠의 형태를 암시해요. 최종 레이아웃을 근사할 수 있을 때 (목록 행, 카드, 단락 등) 단순한 Spinner보다 Skeleton을 선호하세요.

구조

@ghds/sketch-core로 그려진 둔탁한 표면 색상의 스케치 스타일 채워진 도형이 불투명도를 부드럽게 펄스해요. 세 가지 변형 — rect(기본), text(둥근 선), circle(예: 아바타 플레이스홀더) — 이 기본 형태, 반경, 크기를 설정하고, width/height로 재정의할 수 있어요.

변형 및 상태

State Status Notes
펄스 Implemented 로딩 중 불투명도가 완전에서 어둡게 사이로 애니메이션돼요.
동작 감소 Implemented prefers-reduced-motion에서 펄스가 숨겨져요; 플레이스홀더가 정적으로 표시돼요.
호버 / 포커스 / 비활성화 Not implemented Skeleton은 인터랙티브하지 않아요.

사용법

Do

  • 스켈레톤을 실제 콘텐츠와 일치시키세요 — 같은 대략적인 크기와 형태로요.
  • 여러 개를 조합해서 (원 + 텍스트 라인) 카드나 목록 행을 미러링하세요.
  • 스켈레톤이 포함된 영역에 aria-busy를 설정해서 보조 기술이 로딩 중임을 알 수 있게 하세요.

Don't

  • 스켈레톤을 무한정 띄워두지 마세요 — 요청이 완료되면 실제 콘텐츠(또는 에러 상태)로 교체하세요.
  • 스켈레톤 자체로 로딩 알림에 의존하지 마세요 — 설계상 aria-hidden이에요.

접근성

콘텐츠

콘텐츠는 없어요 — Skeleton은 형태만 있어요. width/height와 여러 인스턴스를 사용해 올 레이아웃을 근사하세요.

Props API

React@ghds/react

PropTypeDefaultDescription
variant'rect' | 'text' | 'circle''rect'플레이스홀더 형태.
widthnumber | string—너비 (숫자 ⇒ px). 기본값 100% (circle의 경우 지름).
heightnumber | string—높이 (숫자 ⇒ px). 변형별 기본값.
...restHTMLAttributes<HTMLSpanElement>—네이티브 <span> 속성이 그대로 전달돼요.

Web Components@ghds/web-components

PropTypeDefaultDescription
variant'rect' | 'text' | 'circle''rect'플레이스홀더 형태 (반영된 속성).
widthstring—CSS width. 기본값 100% (circle의 경우 지름).
heightstring—CSS height. 변형별 기본값.

React Native@ghds/react-native

PropTypeDefaultDescription
variant'rect' | 'text' | 'circle''rect'플레이스홀더 형태.
widthDimensionValue—너비. 기본값 100% (circle의 경우 지름).
heightDimensionValue—높이. 변형별 기본값.
testIDstring—쿼리용 테스트 핸들.

코드 예시

// React — @ghds/react
import { Skeleton } from '@ghds/react/skeleton';

<Skeleton variant="circle" />;
<Skeleton variant="text" width="70%" />;
<!-- Web Components — @ghds/web-components -->
<script type="module">
  import '@ghds/web-components/skeleton';
</script>
<gh-skeleton variant="circle"></gh-skeleton>
<gh-skeleton variant="text" width="70%"></gh-skeleton>
// React Native — @ghds/react-native
import { Skeleton } from '@ghds/react-native/skeleton';

<Skeleton variant="text" width="70%" />;

라이브 데모

React @ghds/react

Web Components @ghds/web-components