pypi-streamlit

Description
A faster way to build and share data apps
Author
tessl
Last updated

How to use

npx @tessl/cli registry install tessl/pypi-streamlit@1.50.0

display-elements.md docs/

1
# Display Elements
2
3
Core functions for displaying text, data, charts, and media content. These functions form the foundation of Streamlit's visualization capabilities and enable rich content presentation without HTML knowledge.
4
5
## Capabilities
6
7
### Text Display
8
9
Functions for displaying formatted text content with various styling and formatting options.
10
11
```python { .api }
12
def title(body, anchor=None, *, help=None):
13
"""
14
Display large title text as the main heading of the app.
15
16
Args:
17
body (str): The text to display
18
anchor (str, optional): The anchor name for the header
19
help (str, optional): Tooltip text
20
"""
21
22
def header(body, anchor=None, *, help=None, divider=False):
23
"""
24
Display header text as a section heading.
25
26
Args:
27
body (str): The text to display
28
anchor (str, optional): The anchor name for the header
29
help (str, optional): Tooltip text
30
divider (bool): Whether to show a divider line below
31
"""
32
33
def subheader(body, anchor=None, *, help=None, divider=False):
34
"""
35
Display subheader text as a subsection heading.
36
37
Args:
38
body (str): The text to display
39
anchor (str, optional): The anchor name for the header
40
help (str, optional): Tooltip text
41
divider (bool): Whether to show a divider line below
42
"""
43
44
def caption(body, *, help=None):
45
"""
46
Display small caption text in muted color.
47
48
Args:
49
body (str): The text to display
50
help (str, optional): Tooltip text
51
"""
52
53
def text(body, *, help=None):
54
"""
55
Display fixed-width preformatted text.
56
57
Args:
58
body (str): The text to display
59
help (str, optional): Tooltip text
60
"""
61
62
def markdown(body, *, unsafe_allow_html=False, help=None):
63
"""
64
Display Markdown-formatted text with rich formatting support.
65
66
Args:
67
body (str): Markdown text to display
68
unsafe_allow_html (bool): Whether to allow HTML in markdown
69
help (str, optional): Tooltip text
70
"""
71
72
def latex(body, *, help=None):
73
"""
74
Display LaTeX mathematical expressions using KaTeX.
75
76
Args:
77
body (str): LaTeX expression to display
78
help (str, optional): Tooltip text
79
"""
80
81
def code(body, language=None, *, line_numbers=False, help=None):
82
"""
83
Display code block with syntax highlighting.
84
85
Args:
86
body (str): Code to display
87
language (str, optional): Programming language for syntax highlighting
88
line_numbers (bool): Whether to show line numbers
89
help (str, optional): Tooltip text
90
"""
91
92
def html(body, *, help=None):
93
"""
94
Display raw HTML content.
95
96
Args:
97
body (str): HTML content to display
98
help (str, optional): Tooltip text
99
"""
100
101
def divider():
102
"""Display a horizontal divider line."""
103
```
104
105
### Data Display
106
107
Functions for displaying structured data including tables, dataframes, and key metrics.
108
109
```python { .api }
110
def dataframe(data, width=None, height=None, *, use_container_width=False, hide_index=None, column_order=None, column_config=None):
111
"""
112
Display interactive dataframe with sorting, filtering, and selection.
113
114
Args:
115
data: pandas DataFrame, numpy array, or dict-like data
116
width (int, optional): Width in pixels
117
height (int, optional): Height in pixels
118
use_container_width (bool): Whether to use full container width
119
hide_index (bool, optional): Whether to hide the index column
120
column_order (list, optional): Order of columns to display
121
column_config (dict, optional): Column configuration mapping
122
123
Returns:
124
The displayed data selection if interactive
125
"""
126
127
def data_editor(data, width=None, height=None, *, use_container_width=False, hide_index=None, column_order=None, column_config=None, num_rows="fixed", disabled=None, key=None, on_change=None):
128
"""
129
Display editable dataframe with full editing capabilities.
130
131
Args:
132
data: pandas DataFrame, numpy array, or dict-like data
133
width (int, optional): Width in pixels
134
height (int, optional): Height in pixels
135
use_container_width (bool): Whether to use full container width
136
hide_index (bool, optional): Whether to hide the index column
137
column_order (list, optional): Order of columns to display
138
column_config (dict, optional): Column configuration mapping
139
num_rows (str): Row editing mode ("fixed", "dynamic")
140
disabled (bool or list): Disable editing for columns
141
key (str, optional): Widget key for state management
142
on_change (callable, optional): Callback when data changes
143
144
Returns:
145
The edited dataframe
146
"""
147
148
def table(data, *, help=None):
149
"""
150
Display static table without interactive features.
151
152
Args:
153
data: pandas DataFrame, numpy array, or dict-like data
154
help (str, optional): Tooltip text
155
"""
156
157
def metric(label, value, delta=None, *, delta_color="normal", help=None, label_visibility="visible"):
158
"""
159
Display key metric with optional delta indicator.
160
161
Args:
162
label (str): Metric label
163
value (str or number): Metric value
164
delta (str or number, optional): Change from previous value
165
delta_color (str): Color of delta ("normal", "inverse", "off")
166
help (str, optional): Tooltip text
167
label_visibility (str): Label visibility ("visible", "hidden", "collapsed")
168
"""
169
170
def json(body, *, expanded=False, help=None):
171
"""
172
Display JSON data as expandable tree structure.
173
174
Args:
175
body: JSON-serializable object
176
expanded (bool): Whether to start expanded
177
help (str, optional): Tooltip text
178
"""
179
```
180
181
### Chart Display
182
183
Built-in charting functions for common visualization types with automatic formatting and interactivity.
184
185
```python { .api }
186
def line_chart(data, *, x=None, y=None, color=None, width=None, height=None, use_container_width=False, help=None):
187
"""
188
Display line chart connecting data points.
189
190
Args:
191
data: pandas DataFrame or dict-like data
192
x (str, optional): Column name for x-axis
193
y (str or list, optional): Column name(s) for y-axis
194
color (str, optional): Column name for color grouping
195
width (int, optional): Chart width in pixels
196
height (int, optional): Chart height in pixels
197
use_container_width (bool): Whether to use full container width
198
help (str, optional): Tooltip text
199
"""
200
201
def area_chart(data, *, x=None, y=None, color=None, width=None, height=None, use_container_width=False, help=None):
202
"""
203
Display area chart with filled regions under lines.
204
205
Args:
206
data: pandas DataFrame or dict-like data
207
x (str, optional): Column name for x-axis
208
y (str or list, optional): Column name(s) for y-axis
209
color (str, optional): Column name for color grouping
210
width (int, optional): Chart width in pixels
211
height (int, optional): Chart height in pixels
212
use_container_width (bool): Whether to use full container width
213
help (str, optional): Tooltip text
214
"""
215
216
def bar_chart(data, *, x=None, y=None, color=None, width=None, height=None, use_container_width=False, help=None):
217
"""
218
Display bar chart with categorical data.
219
220
Args:
221
data: pandas DataFrame or dict-like data
222
x (str, optional): Column name for x-axis
223
y (str or list, optional): Column name(s) for y-axis
224
color (str, optional): Column name for color grouping
225
width (int, optional): Chart width in pixels
226
height (int, optional): Chart height in pixels
227
use_container_width (bool): Whether to use full container width
228
help (str, optional): Tooltip text
229
"""
230
231
def scatter_chart(data, *, x=None, y=None, color=None, size=None, width=None, height=None, use_container_width=False, help=None):
232
"""
233
Display scatter plot with individual data points.
234
235
Args:
236
data: pandas DataFrame or dict-like data
237
x (str, optional): Column name for x-axis
238
y (str, optional): Column name for y-axis
239
color (str, optional): Column name for color grouping
240
size (str, optional): Column name for point size
241
width (int, optional): Chart width in pixels
242
height (int, optional): Chart height in pixels
243
use_container_width (bool): Whether to use full container width
244
help (str, optional): Tooltip text
245
"""
246
247
def map(data, *, latitude=None, longitude=None, color=None, size=None, zoom=None, use_container_width=False, help=None):
248
"""
249
Display map with data points overlaid on geographic coordinates.
250
251
Args:
252
data: pandas DataFrame with geographic data
253
latitude (str, optional): Column name for latitude values
254
longitude (str, optional): Column name for longitude values
255
color (str, optional): Column name for color grouping
256
size (str, optional): Column name for point size
257
zoom (int, optional): Initial zoom level
258
use_container_width (bool): Whether to use full container width
259
help (str, optional): Tooltip text
260
"""
261
```
262
263
### Advanced Charts
264
265
Integration with popular charting libraries for sophisticated visualizations.
266
267
```python { .api }
268
def altair_chart(altair_chart, *, use_container_width=False, help=None):
269
"""
270
Display Altair/Vega-Lite chart with full customization.
271
272
Args:
273
altair_chart: Altair Chart object
274
use_container_width (bool): Whether to use full container width
275
help (str, optional): Tooltip text
276
"""
277
278
def vega_lite_chart(data, spec, *, use_container_width=False, help=None):
279
"""
280
Display chart using Vega-Lite specification.
281
282
Args:
283
data: Chart data
284
spec (dict): Vega-Lite specification
285
use_container_width (bool): Whether to use full container width
286
help (str, optional): Tooltip text
287
"""
288
289
def plotly_chart(figure_or_data, *, use_container_width=False, sharing="streamlit", help=None):
290
"""
291
Display interactive Plotly chart with full interactivity.
292
293
Args:
294
figure_or_data: Plotly Figure object or data
295
use_container_width (bool): Whether to use full container width
296
sharing (str): Sharing mode for Plotly
297
help (str, optional): Tooltip text
298
"""
299
300
def bokeh_chart(figure, *, use_container_width=False, help=None):
301
"""
302
Display Bokeh plot with interactive capabilities.
303
304
Args:
305
figure: Bokeh Figure object
306
use_container_width (bool): Whether to use full container width
307
help (str, optional): Tooltip text
308
"""
309
310
def pyplot(fig=None, *, clear_figure=None, use_container_width=False, help=None):
311
"""
312
Display Matplotlib figure with optional automatic clearing.
313
314
Args:
315
fig (matplotlib.figure.Figure, optional): Figure to display
316
clear_figure (bool, optional): Whether to clear figure after display
317
use_container_width (bool): Whether to use full container width
318
help (str, optional): Tooltip text
319
"""
320
321
def graphviz_chart(figure_or_dot, *, use_container_width=False, help=None):
322
"""
323
Display Graphviz diagram from DOT notation or figure.
324
325
Args:
326
figure_or_dot: Graphviz figure or DOT string
327
use_container_width (bool): Whether to use full container width
328
help (str, optional): Tooltip text
329
"""
330
331
def pydeck_chart(pydeck_obj, *, use_container_width=False, help=None):
332
"""
333
Display 3D visualization using PyDeck for geographic data.
334
335
Args:
336
pydeck_obj: PyDeck chart object
337
use_container_width (bool): Whether to use full container width
338
help (str, optional): Tooltip text
339
"""
340
```
341
342
### Media Display
343
344
Functions for displaying images, audio, video, and document content.
345
346
```python { .api }
347
def image(image, caption=None, width=None, *, use_column_width=None, clamp=False, channels="RGB", output_format="auto", help=None):
348
"""
349
Display image with optional caption and sizing controls.
350
351
Args:
352
image: PIL Image, numpy array, or image URL/path
353
caption (str, optional): Image caption
354
width (int, optional): Image width in pixels
355
use_column_width (bool, optional): Whether to use column width
356
clamp (bool): Whether to clamp image values to valid range
357
channels (str): Color channel format ("RGB", "BGR")
358
output_format (str): Output format ("PNG", "JPEG", "auto")
359
help (str, optional): Tooltip text
360
"""
361
362
def audio(data, *, format="audio/wav", start_time=0, sample_rate=None, help=None, loop=False, autoplay=False, end_time=None):
363
"""
364
Display audio player with playback controls.
365
366
Args:
367
data: Audio data as bytes, file path, or URL
368
format (str): MIME type of audio format
369
start_time (int): Start playback time in seconds
370
sample_rate (int, optional): Sample rate for raw audio
371
help (str, optional): Tooltip text
372
loop (bool): Whether to loop playback
373
autoplay (bool): Whether to start playing automatically
374
end_time (int, optional): End playback time in seconds
375
"""
376
377
def video(data, *, format="video/mp4", start_time=0, help=None, loop=False, autoplay=False, subtitles=None, end_time=None, muted=False):
378
"""
379
Display video player with full playback controls.
380
381
Args:
382
data: Video data as bytes, file path, or URL
383
format (str): MIME type of video format
384
start_time (int): Start playback time in seconds
385
help (str, optional): Tooltip text
386
loop (bool): Whether to loop playback
387
autoplay (bool): Whether to start playing automatically
388
subtitles (str, optional): Subtitle file path or URL
389
end_time (int, optional): End playback time in seconds
390
muted (bool): Whether to start muted
391
"""
392
393
def pdf(data, *, width=None, help=None):
394
"""
395
Display PDF document with page navigation and zoom controls.
396
397
Args:
398
data: PDF data as bytes, file path, or URL
399
width (int, optional): Display width in pixels
400
help (str, optional): Tooltip text
401
"""
402
```
403
404
### Utility Display Functions
405
406
Additional display functions for badges, help, and generic content.
407
408
```python { .api }
409
def badge(label, *, icon=None, color="blue"):
410
"""
411
Display small badge with text content.
412
413
Args:
414
label (str): Badge text content
415
icon (str, optional): Optional icon or emoji
416
color (str, optional): Badge color ("red", "orange", "yellow", "blue", "green", "violet", "gray", "grey", "primary")
417
"""
418
419
def help(obj):
420
"""
421
Display help information about Python objects, functions, or modules.
422
423
Args:
424
obj: Python object to display help for
425
"""
426
427
def write(*args, unsafe_allow_html=False):
428
"""
429
Universal display function that automatically formats various data types.
430
431
Args:
432
*args: Variable arguments of any type to display
433
unsafe_allow_html (bool): Whether to allow HTML in strings
434
"""
435
436
def write_stream(stream, *, help=None):
437
"""
438
Display streaming content with real-time updates.
439
440
Args:
441
stream: Iterable that yields content to display
442
help (str, optional): Tooltip text
443
"""
444
445
def echo(code_location="above"):
446
"""
447
Display the code that is being executed in the current context.
448
449
Args:
450
code_location (str): Where to show code ("above" or "below")
451
"""
452
```