Insert a popover container.
Inserts a multi-element container as a popover. It consists of a button-like element and a container that opens when the button is clicked.
Opening and closing the popover will not trigger a rerun. Interacting with widgets inside of an open popover will rerun the app while keeping the popover open. Clicking outside of the popover will close it.
To add elements to the returned container, you can use the "with" notation (preferred) or just call methods directly on the returned object. See examples below.
Warning
You may not put a popover inside another popover.
Function signature[source] | |
---|---|
st.popover(label, *, help=None, disabled=False, use_container_width=False) | |
Parameters | |
label (str) | The label of the button that opens the popover container. The label can optionally contain Markdown and supports the following elements: Bold, Italics, Strikethroughs, Inline Code, Emojis, and Links. This also supports:
Unsupported elements are unwrapped so only their children (text contents) render. Display unsupported elements as literal characters by backslash-escaping them. E.g. 1\. Not an ordered list. |
help (str) | An optional tooltip that gets displayed when the popover button is hovered over. |
disabled (bool) | An optional boolean, which disables the popover button if set to True. The default is False. |
use_container_width (bool) | An optional boolean, which makes the popover button stretch its width to match the parent container. This only affects the button and not the width of the popover container. |
Examples
You can use the with notation to insert any element into a popover:
import streamlit as st with st.popover("Open popover"): st.markdown("Hello World 👋") name = st.text_input("What's your name?") st.write("Your name:", name)Or you can just call methods directly on the returned objects:
import streamlit as st popover = st.popover("Filter items") red = popover.checkbox("Show red items.", True) blue = popover.checkbox("Show blue items.", True) if red: st.write(":red[This is a red item.]") if blue: st.write(":blue[This is a blue item.]")
Still have questions?
Our forums are full of helpful information and Streamlit experts.