Show API reference for

Display a skeleton loading placeholder.

A skeleton is an animated placeholder that indicates content is loading. Use it to reserve layout space and provide visual feedback while content loads. It can be used in two ways:

Standalone mode (like st.empty()): Returns a placeholder that is shown immediately and can be replaced with content later by calling an st.* method on it (for example, placeholder.dataframe(...)).

Context manager mode (like st.spinner(), recommended): The skeleton is shown while the with block runs (after a short delay) and automatically clears when the block exits, whether normally or due to an exception. Like st.spinner, any st.* calls made inside the with block are written to the parent container and remain visible after the skeleton clears.

Note

Context manager mode is recommended. Use standalone mode only when you need to reserve a slot and fill it later (like st.empty()).

Function signature[source]

st.skeleton(height=None, *, width="stretch")

Parameters

height (int, "stretch", or None)

The height of the skeleton. This can be one of the following:

  • None (default): The skeleton uses the standard element height (the same height as most input widgets).
  • An integer specifying the height in pixels.
  • "stretch": The height of the skeleton matches the height of the parent container. This requires a parent container with a bounded height.

width (int or "stretch")

The width of the skeleton. This can be one of the following:

  • "stretch" (default): The width of the skeleton matches the width of the parent container.
  • An integer specifying the width in pixels.
Returns

(SkeletonPlaceholder)

A placeholder object that can be used to replace the skeleton with other content, or as a context manager.

Examples

Standalone mode - replace skeleton with content:

import streamlit as st
import time

placeholder = st.skeleton(height=200)
time.sleep(2)
placeholder.dataframe({"col1": [1, 2, 3], "col2": [4, 5, 6]})

Context manager mode - skeleton auto-clears when block exits:

import streamlit as st
import time

with st.skeleton(height=100):
    # Expensive computation runs here
    time.sleep(2)

# Skeleton clears, show results below
st.success("Data loaded!")
forum

Still have questions?

Our forums are full of helpful information and Streamlit experts.