UI Toolbox logoUI Toolbox
Support

Skeleton

A Skeleton is a gray placeholder that shows where content will be while it loads. It pulses slowly. The user sees the layout of the screen before the data arrives, which feels faster than a spinner.

A skeleton card of four gray bars that stand in for lines of text, the last one shorterA skeleton card of four gray bars that stand in for lines of text, the last one shorter

How to show a skeleton while content loads:

  1. Make the skeleton with the layout of the content: a circle for an avatar, lines for text, a block for a picture.
  2. Show the skeleton and hide the content.
  3. When the data is ready, hide the skeleton and show the content.
<ui:VisualElement name="cardSkeleton" style="flex-direction: row;">
    <tb:Skeleton shape="Circle" />
    <tb:Skeleton
        shape="Text"
        lines="3"
        style="flex-grow: 1; margin-left: 8px;" />
</ui:VisualElement>
<ui:VisualElement name="card" style="display: none;">
    <!-- the content -->
</ui:VisualElement>
var profile = await LoadProfileAsync();
card.Q<Label>("name").text = profile.Name;
root.Q("cardSkeleton").style.display = DisplayStyle.None;
card.style.display = DisplayStyle.Flex;
Member Description
Shape (shape) Block (the default): a block that takes the size you give it. Text: lines of text. Circle: a 32 px circle. It sets the class tb-skeleton--block, --text or --circle.
Lines (lines) The number of lines of a Text skeleton (default 1). The last of two or more lines is 60% wide.
Animate (animate) On (the default): the skeleton pulses. Off: it is still.

Tips:

Styling

Class Element
tb-skeleton The control. It has the opacity transition of 0.8 s for the pulse.
tb-skeleton--block, --text, --circle The shape. A block and a circle have the --tb-color-border background; a circle is 32 px.
tb-skeleton__line One line of a Text skeleton: 10 px high with a 3 px margin.
tb-skeleton__line--last The last of two or more lines: 60% wide.
tb-skeleton--dim Opacity 0.45. The control puts this class on and takes it off each 0.8 s.

For a lighter placeholder and a softer pulse (the control changes the class each 0.8 s, so a transition longer than 0.8 s does not complete):

.tb-skeleton--block,
.tb-skeleton--circle,
.tb-skeleton__line {
    background-color: var(--tb-color-surface-hover);
}
.tb-skeleton--dim { opacity: 0.7; }

The SkeletonDemo scene shows a field for each setting of one skeleton, the profile card of a guild member that loads, the slots of a bag that fill one by one, and the looks of the placeholder.