Additional Streamlit in Snowflake features¶
Attention
This feature is available to accounts in AWS, Microsoft Azure, and GCP regions. AWS PrivateLink and Azure Private Link are not supported.
This topic describes additional Streamlit in Snowflake features.
Custom UI in Streamlit in Snowflake¶
Custom UI enables customization of the look, feel, and front-end behavior of Streamlit in Snowflake apps. This feature supports the following:
Custom HTML and CSS using
unsafe_allow_html=True
in st.markdown.Iframed HTML, CSS, and JavaScript using st.components.v1.html.
Note
Custom UI has some restrictions related to the Content Security Policy (CSP). For more information, see Limitations when loading external resources in Streamlit in Snowflake.
Customize your Streamlit in Snowflake apps¶
To start customizing your Streamlit in Snowflake app, simply call st.components.v1.html
, or st.markdown
with unsafe_allow_html=True
.
The provided HTML is added to the app front end in the user’s browser.
Note
You must specify the inline HTML or load the HTML into a string. You cannot pass a URL or a file path directly to the command to run or embed.
See the following examples for customizing your Streamlit in Snowflake apps:
Customize your sidebar background color:
st.markdown(""" <style> [data-testid=stSidebar] { background-color: #94d3e6; } </style> """, unsafe_allow_html=True)
Add an app logo with
streamlit-extras
:Make sure to install the
streamlit-extras
package before running.from streamlit_extras.app_logo import add_logo add_logo("./Logo.png", height=60)
Set the sidebar width programmatically:
import streamlit.components.v1 as components components.html(""" <script> window.parent.document.querySelector('[data-testid="stSidebar"]').style.width = "300px"; </script> """, height=0)
Create an in-browser DataFrame exploratory data analysis (EDA) with
ydata-profiling
:import streamlit as st import streamlit.components.v1 as components from sklearn.datasets import load_iris from ydata_profiling import ProfileReport st.set_page_config(layout="wide") df = load_iris(as_frame=True).data html = ProfileReport(df).to_html() components.html(html, height=500, scrolling=True)
Custom UI in Streamlit apps within the Snowflake Native App Framework¶
Custom UI is currently disabled by default for Streamlit apps within a Snowflake Native App. During this preview, providers can request Snowflake to enable Custom UI for specific application packages.