forked from streamlit/streamlit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathst_expander.py
77 lines (61 loc) · 2.92 KB
/
st_expander.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import streamlit as st
sidebar = st.sidebar.expander("Expand me!")
sidebar.write("I am in the sidebar")
expander = st.expander("Collapse me!", expanded=True)
expander.write("I can collapse")
expander.slider("I don't get cut off")
expander.button("I'm also not cut off (while focused)")
collapsed = st.expander("_Expand_ **me**!")
collapsed.write("I am already collapsed")
st.expander("Empty expander")
with st.expander("Expander with number input", expanded=True):
# We deliberately use a list to implement this for the screenshot
st.write("* Example list item")
value = st.number_input("number", value=1.0, key="number")
def update_value():
st.session_state.number = 0
update_button = st.button("Update Num Input", on_click=update_value)
st.text(st.session_state.get("number"))
if st.button("Print State Value"):
st.text(st.session_state.get("number"))
expander_long = st.expander(
"Expand me! "
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum arcu nisl, tincidunt id "
"orci id, condimentum cursus nunc. Nullam sed sodales ipsum, vel tincidunt dui. Etiam diam "
"dolor, eleifend sit amet purus id, dictum aliquam quam.",
expanded=True,
)
expander_long.write(
"I can collapse. "
"Integer et justo orci. In euismod posuere nulla ac maximus. Mauris tristique hendrerit "
"placerat. Integer eu imperdiet ipsum. Praesent maximus pharetra est, ut ultrices ante "
"molestie id. Nulla sollicitudin arcu orci, eget lobortis lacus ultricies eu. Ut suscipit est "
"eget tellus laoreet faucibus. Nullam nec blandit felis. Nulla ullamcorper, justo eget "
"consequat ultricies, nisi dolor lacinia mauris, eu lacinia ante nisi sit amet tortor."
)
collapsed_long = st.expander(
"Expand me! "
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum arcu nisl, tincidunt id "
"orci id, condimentum cursus nunc. Nullam sed sodales ipsum, vel tincidunt dui. Etiam diam "
"dolor, eleifend sit amet purus id, dictum aliquam quam."
)
collapsed_long.write("I am already collapsed")
expander_material_icon = st.expander(
"Expander with material icon!", icon=":material/bolt:"
).write("This is an expander with a material icon.")
expander_emoji_icon = st.expander("Expander with emoji icon!", icon="🎈").write(
"This is an expander with an emoji icon."
)