WebForms Core 2.3, which is coming soon, introduces a Skeleton structure that allows developers to add loading placeholders to web pages through simple server-side methods.
Skeletons are useful when content takes time to load. Instead of leaving an empty area on the page, developers can display placeholder shapes that represent the expected content layout.
Adding Skeleton Shapes
The server-side AddSkeleton method provides a straightforward way to add Skeleton shapes:
public void AddSkeleton(string inputPlace, string shape, string width = "100") =>
Add("Sk" + inputPlace, shape + (!string.IsNullOrEmpty(width) ? GS + width : ""));
public void AddSkeleton(string inputPlace, string shape, int width) =>
Add("Sk" + inputPlace, shape + GS + width.ToString());
The method accepts three parameters:
- inputPlace: Specifies the target element where the Skeleton will be added.
- shape: Specifies the type of Skeleton shape.
-
width: Defines the shape width as a percentage. Its default value is
100.
The width parameter has two overloads, accepting either a string or an int.
Available Shapes
WebForms Core 2.3 provides ten predefined Skeleton shapes:
| Shape | Purpose |
|---|---|
text |
Represents a line of text |
paragraph |
Represents a paragraph placeholder |
square |
Creates a square placeholder |
triangle |
Creates a triangular placeholder |
rectangle |
Creates a rectangular placeholder |
circle |
Creates a circular placeholder |
avatar |
Represents a profile image placeholder |
image |
Represents an image placeholder |
button |
Represents a button placeholder |
space |
Creates an empty spacing area |
Developers can combine these shapes to represent different content layouts.
Examples
Adding a full-width text placeholder:
AddSkeleton("<main>", "text");
Adding a paragraph with a width of 80%:
AddSkeleton("<main>", "paragraph", 80);
Adding a circular avatar with a width of 15%:
AddSkeleton("<main>", "avatar", 15);
Adding multiple shapes to the same target:
AddSkeleton("<main>", "text", 70);
AddSkeleton("<main>", "circle", 30);
AddSkeleton("<main>", "paragraph", 100);
AddSkeleton("<main>", "button", 40);
These calls allow developers to construct a skeleton layout using a sequence of simple server-side instructions.
Deleting Skeletons
In most cases, explicitly deleting Skeletons is unnecessary. Developers can simply use the SetText method to replace the existing content of the target element, which also removes its Skeleton structure.
However, when explicit removal is needed without replacing the element's content, WebForms Core 2.3 provides DeleteSkeleton:
public void DeleteSkeleton(string inputPlace) =>
Add("Sk" + inputPlace, STX + "d");
Usage:
DeleteSkeleton("<main>");
Conclusion
The Skeleton support in WebForms Core 2.3 provides a simple server-side API for creating and removing loading placeholders. Developers can combine different shapes and widths to represent content layouts without manually constructing each placeholder through server-side HTML generation.
With AddSkeleton and DeleteSkeleton, Skeleton management becomes part of the WebForms Core server-side command workflow.
Related Links
On Elanat:
On GitHub:

Top comments (0)