Insert a multi-element container that can be expanded/collapsed.

Inserts a container into your app that can be used to hold multiple elements and can be expanded or collapsed by the user. When collapsed, all that is visible is the provided label.

To add elements to the returned container, you can use "with" notation (preferred) or just call methods directly on the returned object. See examples below.

Warning

Currently, you may not put expanders inside another expander.

Function signature

st.expander(label, expanded=False)

Parameters

label (str)

A string to use as the header for the expander.

expanded (bool)

If True, initializes the expander in "expanded" state. Defaults to False (collapsed).

Was this page helpful?

editSuggest edits
forum

Still have questions?

Our forums are full of helpful information and Streamlit experts.