Cheat Sheet - Streamlit Docs
Cheat Sheet - Streamlit Docs
Streamlit library
Get started
Cheat Sheet
API reference This is a summary of the docs, as of Streamlit v1.29.0.
Advanced features
Install & Import Command line
Components
streamlit run first_app.py streamlit --help
Roadmap
streamlit run your_script.py
Changelog # Import convention streamlit hello
streamlit docs
Streamlit Community Cloud
streamlit --version
Get started
'dataframe:', my_data_frame
# Display a chat input widget.
st.markdown('_Markdown_') # see *
st.subheader('My sub')
>>> element.add_rows(df2)
Display data
st.dataframe(my_dataframe)
st.help(pandas.DataFrame)
st.altair_chart(chart)
st.get_option(key)
st.bokeh_chart(fig)
st.set_option(key, value)
st.graphviz_chart(fig) st.set_page_config(layout='wide')
st.plotly_chart(fig) st.experimental_get_query_params()
st.pydeck_chart(chart) st.experimental_set_query_params(**params)
st.pyplot(fig)
st.vega_lite_chart(df)
Columns
# Two equal columns:
Optimize performance
>>> col1, col2 = st.columns(2)
>>> col2.write("This is column 2") # E.g. Dataframe computation, storing downloaded data, e
>>> @st.cache_data
>>> col1, col2, col3 = st.columns([3, 1, 1]) ... # Do something expensive and return data
# Executes foo
>>> d2 = foo(ref1)
>>> st.radio('Select one:', [1, 2]) # E.g. TensorFlow session, database connection, etc.
>>> @st.cache_resource
>>> st.cache_resource.clear()
Display interactive widgets
st.button("Click me")
st.date_input("Your birthday")
st.time_input("Meeting time") Display progress and status
st.file_uploader("Upload a CSV") # Show a spinner during a process
st.camera_input("Take a picture") >>> with st.spinner(text='In progress'):
st.color_picker("Pick a color") >>> time.sleep(3)
>>> st.success('Done')
# Use widgets' returned values in variables:
st.balloons()
st.snow()
st.toast('Warming up...')
st.error('Error message')
st.warning('Warning message')
st.info('Info message')
st.success('Success message')
st.exception(e)
>>> display_adam_content()
>>> else: