Display elements using the elements() frame
mainAll elements must be rendered within an elements() context manager. The elements() function takes a unique key as a parameter which cannot be reused by another frame or Streamlit widget.
Creating elements with children
You can add children to an element by passing them as arguments or by using a with statement.
from streamlit_elements import elements, mui, html
with elements("my_frame"):
# Single child
mui.Typography("Hello world")
# Multiple children as arguments
mui.Button(
mui.icon.EmojiPeople,
mui.icon.DoubleArrow,
"Button with multiple children"
)
# Multiple children using 'with' statement
with mui.Button:
mui.icon.EmojiPeople()
mui.icon.DoubleArrow()
mui.Typography("Button with multiple children")
# Nested children
with mui.Paper:
with mui.Typography:
html.p("Hello world")
html.p("Goodbye world")from streamlit_elements import elements, mui, html
with elements("my_frame"):
mui.Typography("Hello world")
mui.Button(
mui.icon.EmojiPeople,
mui.icon.DoubleArrow,
"Button with multiple children"
)
with mui.Button:
mui.icon.EmojiPeople()
mui.icon.DoubleArrow()
mui.Typography("Button with multiple children")
with mui.Paper:
with mui.Typography:
html.p("Hello world")
html.p("Goodbye world")