For security reasons (XSS), it is not possible to render raw HTML. However, a current workaround is to display the HTML string inside the srcDoc
attribute of an IFrame. Here’s an example:
import dash
import dash_html_components as html
app = dash.Dash()
app.layout = html.Div([
html.Iframe(
# enable all sandbox features
# see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
# this prevents javascript from running inside the iframe
# and other things security reasons
sandbox='',
srcDoc='''
<h3>IFrame</h3>
<script type="text/javascript">
alert("This javascript will not be executed")
</script>
'''
)
])
if __name__ == '__main__':
app.run_server(debug=True)