스켈레톤
스켈레톤 (Skeleton)
스켈레톤은 실제 콘텐츠가 로딩되는 동안 그 자리를 대신 채워 주는 플레이스홀더 컴포넌트예요. 화면이 텅 비어 보이거나 레이아웃이 흔들리는 걸 막아 주면서, 콘텐츠가 곧 나타난다는 자연스러운 느낌을 줘요. 사각형이나 원 같은 다양한 모양과 크기를 지정할 수 있고, 카드·데이터 테이블·리스트 예제도 함께 제공돼요. 접근성도 챙겨져 있어서 스켈레톤에는 aria-hidden이 적용되고, 여러 개를 묶을 땐 컨테이너에 aria-busy를 사용할 수 있어요
출처: 문서
본문
접근성
스크린 리더 Skeleton은 aria-hidden을 "true"로 사용해서 스크린 리더가 무시하도록 해요. 유효한 속성은 모두 루트 엘리먼트로 전달되기 때문에, 필요하다면 더 커스터마이즈할 수 있어요. 여러 개의 스켈레톤을 컨테이너 안에 그룹으로 묶는다면, 로딩 중임을 나타내기 위해 컨테이너 엘리먼트에 aria-busy를 함께 사용할 수도 있어요.
Card
다양한 Skeleton 컴포넌트와 Tailwind CSS 유틸리티를 사용한 Card 구현 예제예요.
import { Component } from '@angular/core';
import { SkeletonModule } from 'primeng/skeleton';
@Component({
template: `
<div class="card">
<div class="rounded border border-surface-200 dark:border-surface-700 p-6 bg-surface-0 dark:bg-surface-900">
<div class="flex mb-4">
<p-skeleton shape="circle" size="4rem" class="mr-2" />
<div>
<p-skeleton width="10rem" class="mb-2" />
<p-skeleton width="5rem" class="mb-2" />
<p-skeleton height=".5rem" />
</div>
</div>
<p-skeleton width="100%" height="150px" />
<div class="flex justify-between mt-4">
<p-skeleton width="4rem" height="2rem" />
<p-skeleton width="4rem" height="2rem" />
</div>
</div>
</div>
`,
standalone: true,
imports: [SkeletonModule]
})
export class SkeletonCardDemo {}
DataTable
다양한 Skeleton 컴포넌트와 Tailwind CSS 유틸리티를 사용한 DataTable 구현 예제예요.
import { Component, OnInit } from '@angular/core';
import { SkeletonModule } from 'primeng/skeleton';
import { TableModule } from 'primeng/table';
@Component({
template: `
<div class="card">
<p-table [value]="products" [tableStyle]="{ 'min-width': '50rem' }">
<ng-template #header>
<tr>
<th>Code</th>
<th>Name</th>
<th>Category</th>
<th>Quantity</th>
</tr>
</ng-template>
<ng-template #body let-product>
<tr>
<td><p-skeleton /></td>
<td><p-skeleton /></td>
<td><p-skeleton /></td>
<td><p-skeleton /></td>
</tr>
</ng-template>
</p-table>
</div>
`,
standalone: true,
imports: [SkeletonModule, TableModule]
})
export class SkeletonDatatableDemo implements OnInit {
products: any[] | undefined;
ngOnInit() {
this.products = Array.from({ length: 5 }).map((_, i) => `Item #${i}`);
}
}
List
다양한 Skeleton 컴포넌트와 Tailwind CSS 유틸리티를 사용한 List 구현 예제예요.
import { Component } from '@angular/core';
import { SkeletonModule } from 'primeng/skeleton';
@Component({
template: `
<div class="card">
<div class="rounded border border-surface-200 dark:border-surface-700 p-6 bg-surface-0 dark:bg-surface-900">
<ul class="m-0 p-0 list-none">
<li class="mb-4">
<div class="flex">
<p-skeleton shape="circle" size="4rem" class="mr-2" />
<div class="self-center" style="flex: 1">
<p-skeleton width="100%" class="mb-2" />
<p-skeleton width="75%" />
</div>
</div>
</li>
<li class="mb-4">
<div class="flex">
<p-skeleton shape="circle" size="4rem" class="mr-2" />
<div class="self-center" style="flex: 1">
<p-skeleton width="100%" class="mb-2" />
<p-skeleton width="75%" />
</div>
</div>
</li>
<li class="mb-4">
<div class="flex">
<p-skeleton shape="circle" size="4rem" class="mr-2" />
<div class="self-center" style="flex: 1">
<p-skeleton width="100%" class="mb-2" />
<p-skeleton width="75%" />
</div>
</div>
</li>
<li>
<div class="flex">
<p-skeleton shape="circle" size="4rem" class="mr-2" />
<div class="self-center" style="flex: 1">
<p-skeleton width="100%" class="mb-2" />
<p-skeleton width="75%" />
</div>
</div>
</li>
</ul>
</div>
</div>
`,
standalone: true,
imports: [SkeletonModule]
})
export class SkeletonListDemo {}
모양
shape , width , height , borderRadius , class 같은 스타일링 속성을 사용하면 다양한 모양과 크기를 만들 수 있어요.
import { Component } from '@angular/core';
import { SkeletonModule } from 'primeng/skeleton';
@Component({
template: `
<div class="card">
<div class="flex flex-wrap">
<div class="w-full xl:w-6/12 p-4">
<h5>Rectangle</h5>
<p-skeleton class="mb-2" />
<p-skeleton width="10rem" class="mb-2" />
<p-skeleton width="5rem" class="mb-2" />
<p-skeleton height="2rem" class="mb-2" />
<p-skeleton width="10rem" height="4rem" />
</div>
<div class="w-full xl:w-6/12 p-4">
<h5>Rounded</h5>
<p-skeleton class="mb-2" borderRadius="16px" />
<p-skeleton width="10rem" class="mb-2" borderRadius="16px" />
<p-skeleton width="5rem" class="mb-2" borderRadius="16px" />
<p-skeleton height="2rem" class="mb-2" borderRadius="16px" />
<p-skeleton width="10rem" height="4rem" borderRadius="16px" />
</div>
<div class="w-full xl:w-6/12 p-4">
<h5 class="mt-4">Square</h5>
<div class="flex items-end">
<p-skeleton size="2rem" class="mr-2" />
<p-skeleton size="3rem" class="mr-2" />
<p-skeleton size="4rem" class="mr-2" />
<p-skeleton size="5rem" />
</div>
</div>
<div class="field w-full xl:w-6/12 p-4">
<h5 class="mt-4">Circle</h5>
<div class="flex items-end">
<p-skeleton shape="circle" size="2rem" class="mr-2" />
<p-skeleton shape="circle" size="3rem" class="mr-2" />
<p-skeleton shape="circle" size="4rem" class="mr-2" />
<p-skeleton shape="circle" size="5rem" />
</div>
</div>
</div>
</div>
`,
standalone: true,
imports: [SkeletonModule]
})
export class SkeletonShapesDemo {}
Skeleton
Skeleton은 실제 콘텐츠 대신 표시되는 플레이스홀더예요.
Props
| 이름 | 타입 | 기본값 | 설명 |
|---|---|---|---|
| dt | InputSignal | undefined | 컴포넌트의 스코프 디자인 토큰을 정의해요. |
| unstyled | InputSignal | undefined | 컴포넌트를 스타일 없이 렌더링할지 여부를 나타내요. |
| pt | InputSignal | undefined | 컴포넌트 내부의 DOM 엘리먼트에 속성을 전달할 때 사용해요. |
| ptOptions | InputSignal | undefined | 컴포넌트의 passthrough(pt) 옵션을 구성할 때 사용해요. |
| styleClass | string | - | 엘리먼트의 클래스예요. (지원 중단) |
| shape | string | rectangle | 엘리먼트의 모양이에요. |
| borderRadius | string | - | 엘리먼트의 보더 반경이에요. 기본값은 테마의 값을 따라요. |
| size | string | - | 스켈레톤의 크기예요. |
| width | string | 100% | 엘리먼트의 너비예요. |
| height | string | 1rem | 엘리먼트의 높이예요. |
Pass Through 옵션
| 이름 | 타입 | 설명 |
|---|---|---|
| host | PassThroughOption<HTMLElement, I> | 호스트의 DOM 엘리먼트에 속성을 전달할 때 사용해요. |
| root | PassThroughOption<HTMLDivElement, I> | 루트의 DOM 엘리먼트에 속성을 전달할 때 사용해요. |
테밍
CSS 클래스
| 클래스 | 설명 |
|---|---|
| p-skeleton | 루트 엘리먼트의 클래스 이름 |
디자인 토큰
| 토큰 | CSS 변수 | 설명 |
|---|---|---|
| skeleton.border.radius | --p-skeleton-border-radius | 루트의 보더 반경 |
| skeleton.background | --p-skeleton-background | 루트의 배경 |
| skeleton.animation.background | --p-skeleton-animation-background | 루트의 애니메이션 배경 |
더 알아보기 (Learn more)
이 문서에는 원문에서 추출한 별도의 관련 문서 링크가 없어요.