Blazor Skeleton Overview
Updated over 6 months ago
The Blazor Skeleton is a loading indicator. What separates it from conventional loaders is that it mimics the page layout by showing elements in a similar shape as the actual content that will appear after loading.
Creating Blazor Skeleton
- Use the
<TelerikSkeleton>tag. - Set the
Visibleparameter to aboolproperty or expression. - Set the
WidthandHeightparameters. - Use the
ShapeTypeparameter to set the shape of the Skeleton.
Basic Skeleton
@* The Telerik UI for Blazor Skeleton component with its basic settings. *@
@if (String.IsNullOrEmpty(Text))
{
<TelerikSkeleton ShapeType="@SkeletonShapeType.Rectangle"
Width="61px"
Height="28px"
Visible="@isVisible"></TelerikSkeleton>
}
else
{
<TelerikButton Size="medium">@Text</TelerikButton>
}
@code {
string Text { get; set; } = string.Empty;
bool isVisible { get; set; }
protected override async Task OnInitializedAsync()
{
isVisible = true;
await Task.Delay(2000);
Text = "Button";
isVisible = false;
}
}
Appearance
The Telerik UI for Blazor Skeleton provides various options to control its visual appearance:
ShapeTypeAnimationType
Skeleton Parameters
The table below, lists the available parameters for the Skeleton component.
| Parameter | Type and Default Value | Description |
|---|---|---|
Class | string | Renders a custom CSS class to the <span class="k-skeleton"> element. |
ShapeType | SkeletonShapeType enum( Text) | Sets the shape. |
AnimationType | SkeletonAnimationType enum( Pulse) | Sets the animation of the Skeleton. |
Width | string | Sets the width of the Skeleton component. Required for every shape. |
Height | string | Sets the height of the Skeleton component. Require for the Circle and Rectangle shapes. The Text shape calculates its own height, but you can override it with the Height parameter. |
Visible | bool( true) | Controls if the Skeleton is rendered on the page. |