Skeleton

Displays a loading placeholder with shimmer or pulse animation effects.

Import

import { Skeleton } from 'heroui-native';

Anatomy

The Skeleton component is a simple wrapper that renders a placeholder for content that is loading. It does not have any child components.

<Skeleton />

Usage

Basic Usage

The Skeleton component creates an animated placeholder while content is loading.

<Skeleton className="h-20 w-full rounded-lg" />

With Content

Show skeleton while loading, then display content when ready.

<Skeleton isLoading={isLoading} className="h-20 rounded-lg">
  <View className="h-20 bg-primary rounded-lg">
    <Text>Loaded Content</Text>
  </View>
</Skeleton>

Animation Variants

Control the animation style with the variant prop.

<Skeleton variant="shimmer" className="h-20 w-full rounded-lg" />
<Skeleton variant="pulse" className="h-20 w-full rounded-lg" />
<Skeleton variant="none" className="h-20 w-full rounded-lg" />

Custom Shimmer Configuration

Customize the shimmer effect with duration, speed, and highlight color.

<Skeleton
  className="h-16 w-full rounded-lg"
  variant="shimmer"
  animation={{
    shimmer: {
      duration: 2000,
      speed: 2,
      highlightColor: 'rgba(59, 130, 246, 0.3)',
    },
  }}
>
  ...
</Skeleton>

Custom Pulse Configuration

Configure pulse animation with duration and opacity range.

<Skeleton
  className="h-16 w-full rounded-lg"
  variant="pulse"
  animation={{
    pulse: {
      duration: 500,
      minOpacity: 0.1,
      maxOpacity: 0.8,
    },
  }}
>
  ...
</Skeleton>

Shape Variations

Create different skeleton shapes using className for styling.

<Skeleton className="h-4 w-full rounded-md" />
<Skeleton className="h-4 w-3/4 rounded-md" />
<Skeleton className="h-4 w-1/2 rounded-md" />
<Skeleton className="size-12 rounded-full" />

Custom Enter/Exit Animations

Apply custom Reanimated transitions when skeleton appears or disappears.

<Skeleton
  entering={FadeIn.duration(300)}
  exiting={FadeOut.duration(300)}
  isLoading={isLoading}
  className="h-20 w-full rounded-lg"
>
  ...
</Skeleton>

Example

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

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

  return (
    <Card className="p-4">
      <View className="flex-row items-center gap-3 mb-4">
        <Skeleton isLoading={isLoading} 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>
        </Skeleton>

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

      <Skeleton
        isLoading={isLoading}
        className="h-48 w-full rounded-lg"
        animation={{
          shimmer: {
            duration: 1500,
            speed: 1,
          },
        }}
      >
        <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>
      </Skeleton>
    </Card>
  );
}

API Reference

Skeleton

proptypedefaultdescription
childrenReact.ReactNode-Content to show when not loading
isLoadingbooleantrueWhether the skeleton is currently loading
variant'shimmer' | 'pulse' | 'none''shimmer'Animation variant
animationSkeletonRootAnimation-Animation configuration
classNamestring-Additional CSS classes for styling
...Animated.ViewPropsAnimatedProps<ViewProps>-All Reanimated Animated.View props are supported

SkeletonRootAnimation

Animation configuration for Skeleton component. Can be:

  • false or "disabled": Disable only root animations
  • "disable-all": Disable all animations including children
  • true or undefined: Use default animations
  • object: Custom animation configuration
proptypedefaultdescription
entering.valueEntryOrExitLayoutTypeFadeInCustom entering animation
exiting.valueEntryOrExitLayoutTypeFadeOutCustom exiting animation
shimmer.durationnumber1500Animation duration in milliseconds
shimmer.speednumber1Speed multiplier for the animation
shimmer.highlightColorstring-Highlight color for the shimmer effect
shimmer.easingEasingFunctionEasing.linearEasing function for the animation
pulse.durationnumber1000Animation duration in milliseconds
pulse.minOpacitynumber0.5Minimum opacity value
pulse.maxOpacitynumber1Maximum opacity value
pulse.easingEasingFunctionEasing.inOut(Easing.ease)Easing function for the animation

On this page