Skeleton

alpha, RSC
Show a placeholder during content loading to indicate that the content is being fetched.
Installation
API Reference
This is an illustration of Skeleton component.
<Box className="w-[325px] gap-4 p-3 rounded-md bg-background-100">
<Skeleton variant="sharp" className="h-[150px]" />
<SkeletonText _lines={3} className="h-3" />
<HStack className="gap-2 align-middle">
<Skeleton variant="circular" className="h-[24px] w-[24px] mr-2" />
<SkeletonText _lines={2} gap={1} className="h-2 w-2/5" />
</HStack>
</Box>

Installation

Run the following command:

npx gluestack-ui add skeleton

API Reference

To use this component in your project, include the following import statement in your file.
import { Skeleton, SkeletonText } from "@/components/ui/skeleton"
export default () => (
<Box className="gap-2">
<Skeleton variant="rounded" className="h-32 w-64" />
<SkeletonText className="h-4 w-64 " />
</Box>
)

Component Props

This section provides a comprehensive reference list for the component props, detailing descriptions, properties, types, and default behavior for easy project integration.

Skeleton

Renders a <div /> on web and a Animated.View on native and has the following properties:
Platform
Output
Web
<div />
Native
<View />
Prop
Type
Default
Description
variant
rounded | sharp | circular
rounded
Shape of the skeleton component
startColor
string
bg-background-200
Sets the color of the skeleton animation
isLoaded
bool
false
When true, the skeleton content will be displayed
speed
number
2
Sets the animation speed of the skeleton component

SkeletonText

Renders a <div /> on web and a Animated.View on native and has the following properties:
Platform
Output
Web
<div />
Native
<View />
Prop
Type
Default
Description
_lines
number
-
Number of lines in text skeleton
startColor
string
bg-background-200
Sets the color of the skeleton animation
isLoaded
bool
false
When true, the skeleton content will be displayed
speed
number
2
Sets the animation speed of the skeleton component
gap
number
-
Sets the gap between the text skeletons

Examples

The Examples section provides visual representations of the different variants of the component, allowing you to quickly and easily determine which one best fits your needs. Simply copy the code and integrate it into your project.

Using isLoaded prop

Use the isLoaded prop to show the content after the skeleton content is loaded.
isLoaded
<Box className="w-[290px] h-[400px] p-4 rounded-sm bg-background-100 gap-3">
<Skeleton variant="rounded" className="h-44 w-64 rounded-sm" isLoaded={false}>
<Image
className="h-44 w-64 rounded-sm"
source={{
uri: "https://images.unsplash.com/photo-1715006020121-dd50879f9821?q=80&w=2787&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
}}
/>
</Skeleton>
<VStack className="gap-2">
<Text className="text-primary-700 text-sm">May 15, 2023</Text>
<Text className="text-primary-900 font-bold">
The Power of Positive Thinking
</Text>
<Text className="text-primary-700 text-sm">
Discover how the power of positive thinking can transform your life, boost
your confidence, and help you overcome challenges.
</Text>
</VStack>
<HStack className="gap-2">
<Avatar size="xs">
<AvatarFallbackText>John Smith</AvatarFallbackText>
</Avatar>
<Text className="text-sm font-bold">John Smith</Text>
</HStack>
</Box>