Skeleton
The Skeleton component is a versatile component designed to act as a placeholder while content is loading or before the content is available. It provides visual feedback and reduces the perceived loading time for users, improving the overall user experience. It is inspired by the Material-UI skeleton component and can be used in various scenarios such as text, cards, and images.
Importing
_10import { Skeleton } from '@ef-global/backpack/Skeleton';
Props
| Name | Type | Default | Description |
| variant | SkeletonVariant | 'text' | Defines the shape of the skeleton: 'circular', 'rectangular', or 'text'. |
| animate | boolean | true | Determines whether the skeleton should have a pulsing animation effect. |
| height | string | Sets the height of the skeleton. | |
| width | string | Sets the width of the skeleton. | |
| className | string | Custom CSS class name for the skeleton. | |
| children | React.ReactNode | Child elements to be rendered within the skeleton component. |
Usage
Here are some examples of the Skeleton component in use:
With Text
header1
header2
header3
header4
header5
header6
body
bodySmall
_24<Text variant={'header1'}>_24 <Skeleton />_24</Text>_24<Text variant={'header2'}>_24 <Skeleton />_24</Text>_24<Text variant={'header3'}>_24 <Skeleton />_24</Text>_24<Text variant={'header4'}>_24 <Skeleton />_24</Text>_24<Text variant={'header5'}>_24 <Skeleton />_24</Text>_24<Text variant={'header6'}>_24 <Skeleton />_24</Text>_24<Text variant={'body'}>_24 <Skeleton />_24</Text>_24<Text variant={'bodySmall'}>_24 <Skeleton />_24</Text>
With Content Card
_17<ContentCard href='' shadow='off'>_17 <Skeleton_17 style={{ paddingTop: '56.25%' }}_17 variant='rectangular'_17 data-slot='CardImage'_17 />_17 <Skeleton_17 style={{_17 flex: '1',_17 maxWidth: '70%',_17 }}_17 data-slot='CardTitle' />_17 <div data-slot='CardBody'>_17 <Skeleton style={{ maxWidth: '100%' }} />_17 <Skeleton style={{ maxWidth: '30%' }} />_17 </div>_17</ContentCard>
With Teaser Card
_20<TeaserCard className={styles.teaserCardSkeleton} href='' shadow='off'>_20 <Skeleton_20 style={{ paddingTop: '56.25%' }}_20 variant='rectangular'_20 data-slot='CardImage'_20 />_20 <Skeleton_20 style={{_20 flex: '1',_20 backgroundColor: 'hsl(0, 0%, 95%)',_20 maxWidth: '80%',_20 }}_20 animate={false}_20 data-slot='CardTitle'_20 />_20 <div data-slot='CardBody'>_20 <Skeleton style={{ maxWidth: '100%' }} />_20 <Skeleton style={{ maxWidth: '30%' }} />_20 </div>_20</TeaserCard>
)