Skeleton
Skeleton
is used to display the loading state of some components.
Import#
import { Skeleton, SkeletonCircle, SkeletonText } from "@chakra-ui/react"
Usage#
You can use it as a standalone component.
Editable Example
Or to wrap another component to take the same height and width.
contents wrapped
won't be visible
Editable Example
Useful when fetching remote data.
import { Box } from "@chakra-ui/react"function Card() {const { data, loading, error } = useRemoteData()if (error) return <Box children="error" />return (<Box><Skeleton isLoaded={!loading}><Heading>{data.title}</Heading></Skeleton></Box>)}
Circle and Text Skeleton#
Editable Example
Skeleton color#
You can change the animation color with colorStart
and colorEnd
.
Editable Example
Skipping the skeleton when content is loaded#
You can prevent the skeleton from rendering using the isLoaded
prop.
Chakra ui is cool
Editable Example
Props#
Name | Type | Description | Default |
---|---|---|---|
colorScheme | string | - | |
endColor | string | The color at the animation end | - |
fadeDuration | number | The fadeIn duration in seconds | 0.4 |
isLoaded | boolean | If `true`, it'll render its children with a nice fade transition | - |
size | string | - | |
speed | number | The animation speed in seconds | 0.8 |
startColor | string | The color at the animation start | - |
variant | string | - |