본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

SkeletonGroup (스켈레톤 그룹)

원문 보기 위키 갱신

SkeletonGroup는 여러 스켈레톤 로딩 플레이스홀더를 중앙집중식 애니메이션 제어로 조율하는 컴포넌트예요. 그룹 전체의 로딩 상태와 애니메이션을 한 번에 관리하면서 각각의 아이템도 개별적으로 커스터마이징할 수 있어요.

출처: 문서

본문

가져오기 (Import)

import { SkeletonGroup } from 'heroui-native';

구조 (Anatomy)

<SkeletonGroup>
  <SkeletonGroup.Item />
</SkeletonGroup>
  • SkeletonGroup: 모든 스켈레톤 아이템에 중앙집중식 제어를 제공하는 루트 컨테이너
  • SkeletonGroup.Item: 부모 그룹에서 프롭을 상속받는 개별 스켈레톤 아이템

사용법 (Usage)

기본 사용법 (Basic Usage)

SkeletonGroup 컴포넌트는 공유된 로딩 상태와 애니메이션으로 여러 스켈레톤 아이템을 관리해요.

<SkeletonGroup isLoading={isLoading}>
  <SkeletonGroup.Item className="h-4 w-full rounded-md" />
  <SkeletonGroup.Item className="h-4 w-3/4 rounded-md" />
  <SkeletonGroup.Item className="h-4 w-1/2 rounded-md" />
</SkeletonGroup>

컨테이너 레이아웃과 함께 (With Container Layout)

그룹의 className을 사용해 스켈레톤 아이템의 레이아웃을 제어해요.

<SkeletonGroup isLoading={isLoading} className="flex-row items-center gap-3">
  <SkeletonGroup.Item className="h-12 w-12 rounded-lg" />
  <View className="flex-1 gap-1.5">
    <SkeletonGroup.Item className="h-4 w-full rounded-md" />
    <SkeletonGroup.Item className="h-3 w-2/3 rounded-md" />
  </View>
</SkeletonGroup>

순수 스켈레톤 레이아웃에 isSkeletonOnly 사용하기 (With isSkeletonOnly for Pure Skeleton Layouts)

그룹이 로딩 상태에서 렌더링할 콘텐츠가 없는 레이아웃 래퍼(예: View)와 스켈레톤 플레이스홀더만 포함할 때 isSkeletonOnly를 사용해요. 이 프롭은 isLoading이 false일 때 그룹 전체를 숨겨서 빈 컨테이너가 레이아웃에 영향을 주지 않게 해요.

<SkeletonGroup
  isLoading={isLoading}
  isSkeletonOnly // Hides entire group when isLoading is false
  className="flex-row items-center gap-3"
>
  <SkeletonGroup.Item className="h-12 w-12 rounded-lg" />
  {/* This View is only for layout, no content */}
  <View className="flex-1 gap-1.5">
    <SkeletonGroup.Item className="h-4 w-full rounded-md" />
    <SkeletonGroup.Item className="h-3 w-2/3 rounded-md" />
  </View>
</SkeletonGroup>

애니메이션 variant와 함께 (With Animation Variants)

그룹의 모든 아이템에 대한 애니메이션 스타일을 제어해요.

<SkeletonGroup isLoading={isLoading} variant="pulse">
  <SkeletonGroup.Item className="h-10 w-10 rounded-full" />
  <SkeletonGroup.Item className="h-4 w-32 rounded-md" />
  <SkeletonGroup.Item className="h-3 w-24 rounded-md" />
</SkeletonGroup>

커스텀 애니메이션 설정과 함께 (With Custom Animation Configuration)

그룹 전체의 shimmer 또는 pulse 애니메이션을 구성해요.

<SkeletonGroup
  isLoading={isLoading}
  variant="shimmer"
  animation={{
    shimmer: {
      duration: 2000,
      highlightColor: 'rgba(59, 130, 246, 0.3)',
    },
  }}
>
  <SkeletonGroup.Item className="h-16 w-full rounded-lg" />
  <SkeletonGroup.Item className="h-4 w-3/4 rounded-md" />
</SkeletonGroup>

진입/퇴장 애니메이션과 함께 (With Enter/Exit Animations)

그룹이 나타나거나 사라질 때 Reanimated 전환을 적용해요.

<SkeletonGroup
  entering={FadeInLeft}
  exiting={FadeOutRight}
  isLoading={isLoading}
  className="w-full gap-2"
>
  <SkeletonGroup.Item className="h-4 w-full rounded-md" />
  <SkeletonGroup.Item className="h-4 w-3/4 rounded-md" />
</SkeletonGroup>

예제 (Example)

import { Card, SkeletonGroup, Avatar } from 'heroui-native';
import { useState } from 'react';
import { Text, View, Image } from 'react-native';

export default function SkeletonGroupExample() {
  const [isLoading, setIsLoading] = useState(true);

  return (
    <SkeletonGroup isLoading={isLoading}>
      <Card className="p-4">
        <Card.Header>
          <View className="flex-row items-center gap-3 mb-4">
            <SkeletonGroup.Item className="h-10 w-10 rounded-full">
              <Avatar size="sm" alt="Avatar">
                <Avatar.Image
                  source={{ uri: 'https://i.pravatar.cc/150?img=4' }}
                />
                <Avatar.Fallback />
              </Avatar>
            </SkeletonGroup.Item>

            <View className="flex-1 gap-1">
              <SkeletonGroup.Item className="h-3 w-32 rounded-md">
                <Text className="font-semibold text-foreground">John Doe</Text>
              </SkeletonGroup.Item>
              <SkeletonGroup.Item className="h-3 w-24 rounded-md">
                <Text className="text-sm text-muted">@johndoe</Text>
              </SkeletonGroup.Item>
            </View>
          </View>

          <View className="mb-4 gap-1.5">
            <SkeletonGroup.Item className="h-4 w-full rounded-md">
              <Text className="text-base text-foreground">
                This is the first line of the post content.
              </Text>
            </SkeletonGroup.Item>
            <SkeletonGroup.Item className="h-4 w-full rounded-md">
              <Text className="text-base text-foreground">
                Second line with more interesting content to read.
              </Text>
            </SkeletonGroup.Item>
            <SkeletonGroup.Item className="h-4 w-2/3 rounded-md">
              <Text className="text-base text-foreground">
                Last line is shorter.
              </Text>
            </SkeletonGroup.Item>
          </View>
        </Card.Header>

        <SkeletonGroup.Item className="h-48 w-full rounded-lg">
          <View className="h-48 bg-surface-tertiary rounded-lg overflow-hidden">
            <Image
              source={{
                uri: 'https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/backgrounds/cards/car1.jpg',
              }}
              className="h-full w-full"
            />
          </View>
        </SkeletonGroup.Item>
      </Card>
    </SkeletonGroup>
  );
}

더 많은 예제는 GitHub 저장소에서 찾을 수 있어요.

API 참고 (API Reference)

SkeletonGroup

prop type default description
children React.ReactNode - SkeletonGroup.Item components and layout elements
isLoading boolean true Whether the skeleton items are currently loading
isSkeletonOnly boolean false Hides entire group when isLoading is false (for skeleton-only layouts)
variant 'shimmer' | 'pulse' | 'none' 'shimmer' Animation variant for all items in the group
animation SkeletonRootAnimation - Animation configuration
className string - Additional CSS classes for the group container
style StyleProp<ViewStyle> - Custom styles for the group container
...Animated.ViewProps AnimatedProps<ViewProps> - All Reanimated Animated.View props are supported

SkeletonRootAnimation

SkeletonGroup 컴포넌트의 애니메이션 설정이에요. 값은 다음과 같아요:

  • false 또는 "disabled": 루트 애니메이션만 비활성화
  • "disable-all": 자식을 포함한 모든 애니메이션 비활성화
  • true 또는 undefined: 기본 애니메이션 사용
  • object: 커스텀 애니메이션 설정
prop type default description
state 'disabled' | 'disable-all' | boolean - Disable animations while customizing properties
entering.value EntryOrExitLayoutType FadeIn Custom entering animation
exiting.value EntryOrExitLayoutType FadeOut Custom exiting animation
shimmer.duration number 1500 Animation duration in milliseconds
shimmer.speed number 1 Speed multiplier for the animation
shimmer.highlightColor string - Highlight color for the shimmer effect
shimmer.easing EasingFunction Easing.linear Easing function for the animation
pulse.duration number 1000 Animation duration in milliseconds
pulse.minOpacity number 0.5 Minimum opacity value
pulse.maxOpacity number 1 Maximum opacity value
pulse.easing EasingFunction Easing.inOut(Easing.ease) Easing function for the animation

SkeletonGroup.Item

prop type default description
children React.ReactNode - Content to show when not loading
isLoading boolean inherited Whether the skeleton is currently loading (overrides group setting)
variant 'shimmer' | 'pulse' | 'none' inherited Animation variant (overrides group setting)
animation SkeletonRootAnimation inherited Animation configuration (overrides group setting)
className string - Additional CSS classes for styling the item
...Animated.ViewProps AnimatedProps<ViewProps> - All Reanimated Animated.View props are supported

특별 참고 (Special Notes)

프롭 상속 (Props Inheritance)

SkeletonGroup.Item 컴포넌트는 부모 SkeletonGroup에서 모든 애니메이션 관련 프롭을 상속해요:

  • isLoading
  • variant
  • animation

개별 아이템은 자신의 값을 제공해 상속된 프롭을 재정의할 수 있어요.

더 알아보기 (Learn more)