st.iframe
Embed content in an iframe.
st.iframe embeds external URLs, HTML content, or local files in an iframe. It auto-detects the input type and handles it appropriately.
| Function signature[source] | |
|---|---|
st.iframe(src, *, width="stretch", height="content", tab_index=None) | |
| Parameters | |
src (str or Path) | The content to embed. This can be one of the following:
|
width (int, "stretch", or "content") | The width of the iframe. This can be one of the following:
|
height (int, "stretch", or "content") | The height of the iframe. This can be one of the following:
|
tab_index (int or None) | Controls keyboard navigation focus. This can be one of the following:
For more information, see the tabindex documentation on MDN. |
Examples
Embed an external website:
import streamlit as st
st.iframe("https://docs.streamlit.io", height=600)
Embed HTML content directly:
import streamlit as st
st.iframe(
'''
<style>body { font-family: sans-serif; padding: 1rem; }</style>
<p>This is <strong>embedded HTML</strong>.</p>
''',
height=100,
)
Embed a local HTML file:
import streamlit as st
from pathlib import Path
st.iframe(Path("reports/dashboard.html"), height=800)
Still have questions?
Our forums are full of helpful information and Streamlit experts.