Display an HTML string in an iframe.
To use this function, import it from the streamlit.components.v1 module.
If you want to insert HTML text into your app without an iframe, try st.html instead.
Warning
Using st.components.v1.html directly (instead of importing its module) is deprecated and will be disallowed in a later version.
Function signature[source] | |
---|---|
st.components.v1.html(html, width=None, height=None, scrolling=False) | |
Parameters | |
html (str) | The HTML string to embed in the iframe. |
width (int) | The width of the iframe in CSS pixels. By default, this is the app's default element width. |
height (int) | The height of the frame in CSS pixels. By default, this is 150. |
scrolling (bool) | Whether to allow scrolling in the iframe. If this False (default), Streamlit crops any content larger than the iframe and does not show a scrollbar. If this is True, Streamlit shows a scrollbar when the content is larger than the iframe. |
Example
import streamlit.components.v1 as components components.html( "<p><span style='text-decoration: line-through double red;'>Oops</span>!</p>" )
Still have questions?
Our forums are full of helpful information and Streamlit experts.