- Spec files
pypi-streamlit
Describes: pkg:pypi/streamlit@1.50.x
- Description
- A faster way to build and share data apps
- Author
- tessl
- Last updated
display-elements.md docs/
1# Display Elements23Core 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.45## Capabilities67### Text Display89Functions for displaying formatted text content with various styling and formatting options.1011```python { .api }12def title(body, anchor=None, *, help=None):13"""14Display large title text as the main heading of the app.1516Args:17body (str): The text to display18anchor (str, optional): The anchor name for the header19help (str, optional): Tooltip text20"""2122def header(body, anchor=None, *, help=None, divider=False):23"""24Display header text as a section heading.2526Args:27body (str): The text to display28anchor (str, optional): The anchor name for the header29help (str, optional): Tooltip text30divider (bool): Whether to show a divider line below31"""3233def subheader(body, anchor=None, *, help=None, divider=False):34"""35Display subheader text as a subsection heading.3637Args:38body (str): The text to display39anchor (str, optional): The anchor name for the header40help (str, optional): Tooltip text41divider (bool): Whether to show a divider line below42"""4344def caption(body, *, help=None):45"""46Display small caption text in muted color.4748Args:49body (str): The text to display50help (str, optional): Tooltip text51"""5253def text(body, *, help=None):54"""55Display fixed-width preformatted text.5657Args:58body (str): The text to display59help (str, optional): Tooltip text60"""6162def markdown(body, *, unsafe_allow_html=False, help=None):63"""64Display Markdown-formatted text with rich formatting support.6566Args:67body (str): Markdown text to display68unsafe_allow_html (bool): Whether to allow HTML in markdown69help (str, optional): Tooltip text70"""7172def latex(body, *, help=None):73"""74Display LaTeX mathematical expressions using KaTeX.7576Args:77body (str): LaTeX expression to display78help (str, optional): Tooltip text79"""8081def code(body, language=None, *, line_numbers=False, help=None):82"""83Display code block with syntax highlighting.8485Args:86body (str): Code to display87language (str, optional): Programming language for syntax highlighting88line_numbers (bool): Whether to show line numbers89help (str, optional): Tooltip text90"""9192def html(body, *, help=None):93"""94Display raw HTML content.9596Args:97body (str): HTML content to display98help (str, optional): Tooltip text99"""100101def divider():102"""Display a horizontal divider line."""103```104105### Data Display106107Functions for displaying structured data including tables, dataframes, and key metrics.108109```python { .api }110def dataframe(data, width=None, height=None, *, use_container_width=False, hide_index=None, column_order=None, column_config=None):111"""112Display interactive dataframe with sorting, filtering, and selection.113114Args:115data: pandas DataFrame, numpy array, or dict-like data116width (int, optional): Width in pixels117height (int, optional): Height in pixels118use_container_width (bool): Whether to use full container width119hide_index (bool, optional): Whether to hide the index column120column_order (list, optional): Order of columns to display121column_config (dict, optional): Column configuration mapping122123Returns:124The displayed data selection if interactive125"""126127def 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"""129Display editable dataframe with full editing capabilities.130131Args:132data: pandas DataFrame, numpy array, or dict-like data133width (int, optional): Width in pixels134height (int, optional): Height in pixels135use_container_width (bool): Whether to use full container width136hide_index (bool, optional): Whether to hide the index column137column_order (list, optional): Order of columns to display138column_config (dict, optional): Column configuration mapping139num_rows (str): Row editing mode ("fixed", "dynamic")140disabled (bool or list): Disable editing for columns141key (str, optional): Widget key for state management142on_change (callable, optional): Callback when data changes143144Returns:145The edited dataframe146"""147148def table(data, *, help=None):149"""150Display static table without interactive features.151152Args:153data: pandas DataFrame, numpy array, or dict-like data154help (str, optional): Tooltip text155"""156157def metric(label, value, delta=None, *, delta_color="normal", help=None, label_visibility="visible"):158"""159Display key metric with optional delta indicator.160161Args:162label (str): Metric label163value (str or number): Metric value164delta (str or number, optional): Change from previous value165delta_color (str): Color of delta ("normal", "inverse", "off")166help (str, optional): Tooltip text167label_visibility (str): Label visibility ("visible", "hidden", "collapsed")168"""169170def json(body, *, expanded=False, help=None):171"""172Display JSON data as expandable tree structure.173174Args:175body: JSON-serializable object176expanded (bool): Whether to start expanded177help (str, optional): Tooltip text178"""179```180181### Chart Display182183Built-in charting functions for common visualization types with automatic formatting and interactivity.184185```python { .api }186def line_chart(data, *, x=None, y=None, color=None, width=None, height=None, use_container_width=False, help=None):187"""188Display line chart connecting data points.189190Args:191data: pandas DataFrame or dict-like data192x (str, optional): Column name for x-axis193y (str or list, optional): Column name(s) for y-axis194color (str, optional): Column name for color grouping195width (int, optional): Chart width in pixels196height (int, optional): Chart height in pixels197use_container_width (bool): Whether to use full container width198help (str, optional): Tooltip text199"""200201def area_chart(data, *, x=None, y=None, color=None, width=None, height=None, use_container_width=False, help=None):202"""203Display area chart with filled regions under lines.204205Args:206data: pandas DataFrame or dict-like data207x (str, optional): Column name for x-axis208y (str or list, optional): Column name(s) for y-axis209color (str, optional): Column name for color grouping210width (int, optional): Chart width in pixels211height (int, optional): Chart height in pixels212use_container_width (bool): Whether to use full container width213help (str, optional): Tooltip text214"""215216def bar_chart(data, *, x=None, y=None, color=None, width=None, height=None, use_container_width=False, help=None):217"""218Display bar chart with categorical data.219220Args:221data: pandas DataFrame or dict-like data222x (str, optional): Column name for x-axis223y (str or list, optional): Column name(s) for y-axis224color (str, optional): Column name for color grouping225width (int, optional): Chart width in pixels226height (int, optional): Chart height in pixels227use_container_width (bool): Whether to use full container width228help (str, optional): Tooltip text229"""230231def scatter_chart(data, *, x=None, y=None, color=None, size=None, width=None, height=None, use_container_width=False, help=None):232"""233Display scatter plot with individual data points.234235Args:236data: pandas DataFrame or dict-like data237x (str, optional): Column name for x-axis238y (str, optional): Column name for y-axis239color (str, optional): Column name for color grouping240size (str, optional): Column name for point size241width (int, optional): Chart width in pixels242height (int, optional): Chart height in pixels243use_container_width (bool): Whether to use full container width244help (str, optional): Tooltip text245"""246247def map(data, *, latitude=None, longitude=None, color=None, size=None, zoom=None, use_container_width=False, help=None):248"""249Display map with data points overlaid on geographic coordinates.250251Args:252data: pandas DataFrame with geographic data253latitude (str, optional): Column name for latitude values254longitude (str, optional): Column name for longitude values255color (str, optional): Column name for color grouping256size (str, optional): Column name for point size257zoom (int, optional): Initial zoom level258use_container_width (bool): Whether to use full container width259help (str, optional): Tooltip text260"""261```262263### Advanced Charts264265Integration with popular charting libraries for sophisticated visualizations.266267```python { .api }268def altair_chart(altair_chart, *, use_container_width=False, help=None):269"""270Display Altair/Vega-Lite chart with full customization.271272Args:273altair_chart: Altair Chart object274use_container_width (bool): Whether to use full container width275help (str, optional): Tooltip text276"""277278def vega_lite_chart(data, spec, *, use_container_width=False, help=None):279"""280Display chart using Vega-Lite specification.281282Args:283data: Chart data284spec (dict): Vega-Lite specification285use_container_width (bool): Whether to use full container width286help (str, optional): Tooltip text287"""288289def plotly_chart(figure_or_data, *, use_container_width=False, sharing="streamlit", help=None):290"""291Display interactive Plotly chart with full interactivity.292293Args:294figure_or_data: Plotly Figure object or data295use_container_width (bool): Whether to use full container width296sharing (str): Sharing mode for Plotly297help (str, optional): Tooltip text298"""299300def bokeh_chart(figure, *, use_container_width=False, help=None):301"""302Display Bokeh plot with interactive capabilities.303304Args:305figure: Bokeh Figure object306use_container_width (bool): Whether to use full container width307help (str, optional): Tooltip text308"""309310def pyplot(fig=None, *, clear_figure=None, use_container_width=False, help=None):311"""312Display Matplotlib figure with optional automatic clearing.313314Args:315fig (matplotlib.figure.Figure, optional): Figure to display316clear_figure (bool, optional): Whether to clear figure after display317use_container_width (bool): Whether to use full container width318help (str, optional): Tooltip text319"""320321def graphviz_chart(figure_or_dot, *, use_container_width=False, help=None):322"""323Display Graphviz diagram from DOT notation or figure.324325Args:326figure_or_dot: Graphviz figure or DOT string327use_container_width (bool): Whether to use full container width328help (str, optional): Tooltip text329"""330331def pydeck_chart(pydeck_obj, *, use_container_width=False, help=None):332"""333Display 3D visualization using PyDeck for geographic data.334335Args:336pydeck_obj: PyDeck chart object337use_container_width (bool): Whether to use full container width338help (str, optional): Tooltip text339"""340```341342### Media Display343344Functions for displaying images, audio, video, and document content.345346```python { .api }347def image(image, caption=None, width=None, *, use_column_width=None, clamp=False, channels="RGB", output_format="auto", help=None):348"""349Display image with optional caption and sizing controls.350351Args:352image: PIL Image, numpy array, or image URL/path353caption (str, optional): Image caption354width (int, optional): Image width in pixels355use_column_width (bool, optional): Whether to use column width356clamp (bool): Whether to clamp image values to valid range357channels (str): Color channel format ("RGB", "BGR")358output_format (str): Output format ("PNG", "JPEG", "auto")359help (str, optional): Tooltip text360"""361362def audio(data, *, format="audio/wav", start_time=0, sample_rate=None, help=None, loop=False, autoplay=False, end_time=None):363"""364Display audio player with playback controls.365366Args:367data: Audio data as bytes, file path, or URL368format (str): MIME type of audio format369start_time (int): Start playback time in seconds370sample_rate (int, optional): Sample rate for raw audio371help (str, optional): Tooltip text372loop (bool): Whether to loop playback373autoplay (bool): Whether to start playing automatically374end_time (int, optional): End playback time in seconds375"""376377def video(data, *, format="video/mp4", start_time=0, help=None, loop=False, autoplay=False, subtitles=None, end_time=None, muted=False):378"""379Display video player with full playback controls.380381Args:382data: Video data as bytes, file path, or URL383format (str): MIME type of video format384start_time (int): Start playback time in seconds385help (str, optional): Tooltip text386loop (bool): Whether to loop playback387autoplay (bool): Whether to start playing automatically388subtitles (str, optional): Subtitle file path or URL389end_time (int, optional): End playback time in seconds390muted (bool): Whether to start muted391"""392393def pdf(data, *, width=None, help=None):394"""395Display PDF document with page navigation and zoom controls.396397Args:398data: PDF data as bytes, file path, or URL399width (int, optional): Display width in pixels400help (str, optional): Tooltip text401"""402```403404### Utility Display Functions405406Additional display functions for badges, help, and generic content.407408```python { .api }409def badge(label, *, icon=None, color="blue"):410"""411Display small badge with text content.412413Args:414label (str): Badge text content415icon (str, optional): Optional icon or emoji416color (str, optional): Badge color ("red", "orange", "yellow", "blue", "green", "violet", "gray", "grey", "primary")417"""418419def help(obj):420"""421Display help information about Python objects, functions, or modules.422423Args:424obj: Python object to display help for425"""426427def write(*args, unsafe_allow_html=False):428"""429Universal display function that automatically formats various data types.430431Args:432*args: Variable arguments of any type to display433unsafe_allow_html (bool): Whether to allow HTML in strings434"""435436def write_stream(stream, *, help=None):437"""438Display streaming content with real-time updates.439440Args:441stream: Iterable that yields content to display442help (str, optional): Tooltip text443"""444445def echo(code_location="above"):446"""447Display the code that is being executed in the current context.448449Args:450code_location (str): Where to show code ("above" or "below")451"""452```