Skeleton
A Skeleton
component is a loading state that acts as a placeholder for content within an interface.
It is used to indicate that the content is being loaded and to provide a visual representation of the content that will be displayed.
The
Skeleton
component can be used to create a loading state for any type of content, such as text, images, or other components.How it works #
The Skeleton component provides a placeholder UI while content is loading, improving perceived performance and user experience.
How to use:
The demo below shows a basic skeleton block and a skeleton overlaying text content.
How to use:
- Add the
Skeleton
component where you want to display a loading placeholder. - Use it as a self-closing tag for a generic block, or wrap your content inside
<Skeleton>...</Skeleton>
to show a skeleton overlay until the content is ready. - Replace the skeleton with your actual content once loading is complete.
<Skeleton />
The Skeleton component can wrap any content, such as text or paragraphs, to indicate that the content is loading.
How to use:
This demo illustrates a skeleton overlaying a block of text.
How to use:
- Wrap your content inside the
Skeleton
component. - While loading, the skeleton will be shown in place of the content.
- Once loading is complete, display the actual content.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
<Skeleton>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</Skeleton>
Skeleton lines #
The Skeleton component supports a "lines" type for simulating loading text or lists using multiple horizontal lines.
How to use:
The demo below shows the default usage with several skeleton lines.
How to use:
- Set
Type="SkeletonType.Lines"
on theSkeleton
component. - Add one or more
SkeletonLine
elements as children to represent each line. - Customize each line as needed (e.g., width, color).
<Skeleton Type="SkeletonType.Lines">
<SkeletonLine />
<SkeletonLine />
<SkeletonLine />
<SkeletonLine />
<SkeletonLine />
</Skeleton>
Width #
You can customize the width of each skeleton line to better match the expected content layout.
How to use:
The demo below shows skeleton lines with varying widths.
How to use:
- Within a
Skeleton
of typeLines
, set theWidth
parameter on eachSkeletonLine
(value is a percentage). - Use different widths for a more realistic loading effect.
<Skeleton Type="SkeletonType.Lines">
<SkeletonLine Width="60" />
<SkeletonLine Width="75" />
<SkeletonLine Width="25" />
</Skeleton>
Colors #
The Skeleton component supports color customization to match your application's theme.
How to use:
The demo below shows a skeleton block with a primary color.
How to use:
- Set the
Color
parameter on theSkeleton
component to apply a color to the entire skeleton block. - Choose from predefined color options such as
Primary
,Link
,Success
, etc.
<Skeleton Color="SkeletonColor.Primary" />
You can also set different colors for individual skeleton lines for more granular control.
How to use:
The demo below shows skeleton lines with different colors.
How to use:
- Within a
Skeleton
of typeLines
, set theColor
parameter on eachSkeletonLine
to customize its color. - Mix and match colors to simulate various content types or highlight specific areas.
<Skeleton Type="SkeletonType.Lines">
<SkeletonLine Color="SkeletonColor.Primary" />
<SkeletonLine Color="SkeletonColor.Link" />
<SkeletonLine Color="SkeletonColor.Success" />
<SkeletonLine Color="SkeletonColor.Danger" />
<SkeletonLine Color="SkeletonColor.Warning" />
<SkeletonLine Color="SkeletonColor.Info" />
<SkeletonLine Color="SkeletonColor.White" />
<SkeletonLine Color="SkeletonColor.Light" />
<SkeletonLine Color="SkeletonColor.Dark" />
<SkeletonLine Color="SkeletonColor.Black" />
</Skeleton>
Button #
The Skeleton feature can be applied to interactive components like buttons to indicate loading states.
How to use:
The demo below shows multiple buttons with skeleton states and a toggle to simulate loading.
How to use:
- Set the
IsSkeleton
parameter totrue
on theButton
component to display its skeleton state. - Toggle the
IsSkeleton
property in your code to control when the skeleton is shown (e.g., during async operations). - Use this approach for any button style or color.
<Buttons>
<Button IsSkeleton="isSkeleton">Button</Button>
<Button Color="ButtonColor.Link" IsSkeleton="isSkeleton">Link</Button>
<Button Color="ButtonColor.Primary" IsSkeleton="isSkeleton">Primary</Button>
<Button Color="ButtonColor.Success" IsSkeleton="isSkeleton">Success</Button>
<Button Color="ButtonColor.Info" IsSkeleton="isSkeleton">Info</Button>
<Button Color="ButtonColor.Warning" IsSkeleton="isSkeleton">Warning</Button>
<Button Color="ButtonColor.Danger" IsSkeleton="isSkeleton">Danger</Button>
</Buttons>
<Button Color="ButtonColor.Dark" Size="ButtonSize.Small" @onclick="ToggleSkeletonAsync">Toggle Skeleton</Button>
@code{
bool isSkeleton = false;
async Task ToggleSkeletonAsync()
{
isSkeleton = true;
await Task.Delay(3000);
isSkeleton = false;
}
}
Icon #
The Skeleton feature can be applied to icon components to indicate that an icon is loading or unavailable, providing a visual placeholder that matches the expected icon's size and shape.
How to use:
This demo shows how to use skeleton placeholders for icons and how to toggle their loading state programmatically.
How to use:
- Add your icon component (e.g.,
BootstrapIcon
) to the page. - Set the
IsSkeleton
parameter totrue
on theBootstrapIcon
component orGoogleFontIcon
to display its skeleton state. - Toggle the
IsSkeleton
property in your code to control when the skeleton is shown (for example, during asynchronous loading operations). - Once loading is complete, set
IsSkeleton
tofalse
to display the actual icon.
home thumb_up
<BootstrapIcon Name="BootstrapIconName.ReplyAllFill" IsSkeleton="isSkeleton" />
<BootstrapIcon Name="BootstrapIconName.ReplyFill" IsSkeleton="isSkeleton" />
<br /><br />
<GoogleFontIcon Name="GoogleFontIconName.Home" IsSkeleton="isSkeleton" />
<GoogleFontIcon Name="GoogleFontIconName.ThumbUp" IsSkeleton="isSkeleton" />
<div class="mt-5">
<Button Color="ButtonColor.Dark" Size="ButtonSize.Small" @onclick="ToggleSkeletonAsync">Toggle Skeleton</Button>
</div>
@code {
bool isSkeleton = false;
async Task ToggleSkeletonAsync()
{
isSkeleton = true;
await Task.Delay(3000);
isSkeleton = false;
}
}