Skeleton (스켈레톤)
스켈레톤은 콘텐츠가 로딩 중임을 시각적으로 표시하는 컴포넌트예요. 데이터가 아직 준비되지 않았을 때 자리 표시자(placeholder) 역할을 하며, 로딩 완료 후 실제 콘텐츠로 자연스럽게 교체할 수 있답니다.
출처: 문서
본문
Import (불러오기)
import { Skeleton } from "@kobalte/core/skeleton";
// or
import { Root } from "@kobalte/core/skeleton";
// or (deprecated)
import { Skeleton } from "@kobalte/core";
Features (기능)
- 사용자 지정 너비와 높이를 지원해요.
- 원형(circle) 스켈레톤을 지원해요.
- 표시 여부와 애니메이션 속성을 토글할 수 있어요.
Anatomy (구조)
스켈레톤은 다음의 부분들로 이루어져요:
- Skeleton: 스켈레톤의 루트 컨테이너예요.
<Skeleton />
Example (예제)
기본 예제를 통해 스켈레톤의 구조와 스타일링 방식을 확인해 보세요. 인터랙티브한 미리보기는 출처 문서에서 직접 확인할 수 있어요.
Usage (사용법)
Multiple skeletons (여러 스켈레톤)
여러 스켈레톤을 조합하여 프로필 카드처럼 로딩 중인 레이아웃을 표현할 수 있어요. circle prop으로 원형 아바타를, height·radius prop으로 텍스트 영역의 크기를 조절하며, Image 컴포넌트와 함께 사용하면 이미지가 로드되는 동안 자리 표시자 역할을 하게 됩니다.
Toggle example (토글 예제)
visible prop과 ToggleButton을 함께 사용하면 스켈레톤의 표시 여부를 동적으로 제어할 수 있어요. 사용자가 버튼을 토글할 때마다 스켈레톤이 보이거나 숨겨지는 동작을 만들어 낼 수 있답니다.
API Reference (API 참조)
Skeleton
Skeleton은 @kobalte/core/skeleton의 Root 임포트(그리고 더 이상 사용되지 않는 Skeleton.Root)와 동일해요.
| Prop | Description |
|---|---|
| visible | boolean The visible state of the Skeleton. Sets the data-visible data attribute. |
| animate | boolean Whether the skeleton should animate. Sets the data-animate data attribute. |
| width | number The width of the skeleton in px. Defaults to 100%. |
| height | number The height of the skeleton in px. Defaults to auto. |
| radius | number Roundness of the skeleton in px. Sets border-radius. |
| circle | boolean Whether the skeleton should be a circle. Sets border-radius and width to the height. |
| children | JSX.Element The children of the Skeleton. |
| Data attribute | Description |
|---|---|
| data-visible | Present when the Skeleton is visible. |
| data-animate | Present when the Skeleton can animate. |
Rendered elements (렌더링되는 요소)
| Component | Default rendered element |
|---|---|
Skeleton |
div |
더 알아보기 (Learn more)
- Kobalte 시작하기 — 프로젝트 설정
- WAI ARIA 대기 상태 패턴 — 접근성 가이드라인