Skip to content

Commit 3e6f1ec

Browse files
Add list and hide header (#1429)
1 parent 9d13c6a commit 3e6f1ec

1 file changed

Lines changed: 25 additions & 25 deletions

File tree

content/develop/quick-references/api-cheat-sheet.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This is a summary of the docs for the latest version of Streamlit, [v1.55.0](htt
1515

1616
#### Install & Import
1717

18-
```python
18+
```python hideHeader
1919
pip install streamlit
2020

2121
streamlit run first_app.py
@@ -30,7 +30,7 @@ streamlit run first_app.py
3030

3131
#### Pre-release features
3232

33-
```python
33+
```python hideHeader
3434
pip uninstall streamlit
3535
pip install streamlit-nightly --upgrade
3636
```
@@ -43,7 +43,7 @@ Learn more about [experimental features](advanced-features/prerelease#experiment
4343

4444
#### Command line
4545

46-
```python
46+
```python hideHeader
4747
streamlit cache clear
4848
streamlit config show
4949
streamlit docs
@@ -64,7 +64,7 @@ streamlit version
6464

6565
#### Magic commands
6666

67-
```python
67+
```python hideHeader
6868
# Magic commands implicitly
6969
# call st.write().
7070
"_This_ is some **Markdown**"
@@ -79,7 +79,7 @@ my_variable
7979

8080
#### Display text
8181

82-
```python
82+
```python hideHeader
8383
st.write("Most objects") # df, err, func, keras!
8484
st.write(["st", "is <", 3])
8585
st.write_stream(my_generator)
@@ -102,7 +102,7 @@ st.html("<p>Hi!</p>")
102102

103103
#### Display data
104104

105-
```python
105+
```python hideHeader
106106
st.dataframe(my_dataframe)
107107
st.table(data.iloc[0:10])
108108
st.json({"foo":"bar","fu":"ba"})
@@ -116,7 +116,7 @@ st.metric("My metric", 42, 2)
116116

117117
#### Display media
118118

119-
```python
119+
```python hideHeader
120120
st.image("./header.png")
121121
st.logo("logo.jpg")
122122
st.pdf("my_document.pdf")
@@ -131,7 +131,7 @@ st.video(data, subtitles="./subs.vtt")
131131

132132
#### Display charts
133133

134-
```python
134+
```python hideHeader
135135
st.area_chart(df)
136136
st.bar_chart(df)
137137
st.bar_chart(df, horizontal=True)
@@ -170,7 +170,7 @@ To use Bokeh, see our custom component [`streamlit-bokeh`](https://github.com/st
170170

171171
#### Add elements to sidebar
172172

173-
```python
173+
```python hideHeader
174174
# Just add it after st.sidebar:
175175
a = st.sidebar.radio("Select one:", [1, 2])
176176

@@ -185,7 +185,7 @@ with st.sidebar:
185185

186186
#### Columns
187187

188-
```python
188+
```python hideHeader
189189
# Two equal columns:
190190
col1, col2 = st.columns(2)
191191
col1.write("This is column 1")
@@ -209,7 +209,7 @@ with col1:
209209

210210
#### Tabs
211211

212-
```python
212+
```python hideHeader
213213
# Insert containers separated into tabs:
214214
tab1, tab2 = st.tabs(["Tab 1", "Tab2"])
215215
tab1.write("this is tab 1")
@@ -226,7 +226,7 @@ with tab1:
226226

227227
#### Expandable containers
228228

229-
```python
229+
```python hideHeader
230230
expand = st.expander("My label", icon=":material/info:")
231231
expand.write("Inside the expander.")
232232
pop = st.popover("Button label")
@@ -243,7 +243,7 @@ with expand:
243243

244244
#### Control flow
245245

246-
```python
246+
```python hideHeader
247247
# Stop execution immediately:
248248
st.stop()
249249
# Rerun script immediately:
@@ -252,10 +252,10 @@ st.rerun()
252252
st.switch_page("pages/my_page.py")
253253

254254
# Define a navigation widget in your entrypoint file
255-
pg = st.navigation(
255+
pg = st.navigation([
256256
st.Page("page1.py", title="Home", url_path="home", default=True),
257257
st.Page("page2.py", title="Preferences", url_path="settings"),
258-
)
258+
])
259259
pg.run()
260260

261261
# Group multiple widgets:
@@ -287,7 +287,7 @@ fragment_function()
287287

288288
#### Display interactive widgets
289289

290-
```python
290+
```python hideHeader
291291
st.button("Click me")
292292
st.download_button("Download file", data)
293293
st.link_button("Go to gallery", url)
@@ -332,7 +332,7 @@ st.slider("Pick a number", 0, 100, disabled=True)
332332

333333
#### Build chat-based apps
334334

335-
```python
335+
```python hideHeader
336336
# Insert a chat message container.
337337
with st.chat_message("user"):
338338
st.write("Hello 👋")
@@ -354,7 +354,7 @@ Learn how to [Build a basic LLM chat app](/develop/tutorials/llms/build-conversa
354354

355355
#### Mutate data
356356

357-
```python
357+
```python hideHeader
358358
# Add rows to a dataframe after
359359
# showing it.
360360
element = st.dataframe(df1)
@@ -372,7 +372,7 @@ element.add_rows(df2)
372372

373373
#### Display code
374374

375-
```python
375+
```python hideHeader
376376
with st.echo():
377377
st.write("Code will be executed and printed")
378378
```
@@ -383,7 +383,7 @@ with st.echo():
383383

384384
#### Placeholders, help, and options
385385

386-
```python
386+
```python hideHeader
387387
# Replace any single element.
388388
element = st.empty()
389389
element.line_chart(...)
@@ -420,7 +420,7 @@ st.html("<p>Hi!</p>")
420420

421421
#### Connect to data sources
422422

423-
```python
423+
```python hideHeader
424424
st.connection("pets_db", type="sql")
425425
conn = st.connection("sql")
426426
conn = st.connection("snowflake")
@@ -440,7 +440,7 @@ class MyConnection(BaseConnection[myconn.MyConnection]):
440440

441441
###### Cache data objects
442442

443-
```python
443+
```python hideHeader
444444
# E.g. Dataframe computation, storing downloaded data, etc.
445445
@st.cache_data
446446
def foo(bar):
@@ -463,7 +463,7 @@ st.cache_data.clear()
463463

464464
###### Cache global resources
465465

466-
```python
466+
```python hideHeader
467467
# E.g. TensorFlow session, database connection, etc.
468468
@st.cache_resource
469469
def foo(bar):
@@ -490,7 +490,7 @@ st.cache_resource.clear()
490490

491491
#### Display progress and status
492492

493-
```python
493+
```python hideHeader
494494
# Show a spinner during a process
495495
with st.spinner(text="In progress"):
496496
time.sleep(3)
@@ -522,7 +522,7 @@ st.exception(e)
522522

523523
#### Personalize apps for users
524524

525-
```python
525+
```python hideHeader
526526
# Authenticate users
527527
if not st.user.is_logged_in:
528528
st.login("my_provider")

0 commit comments

Comments
 (0)