Closed
Description
I raised this on the community forum here when I wanted to add <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
to the <head>
of my app.
I noticed the <head>
section gets defined by the index()
function and so created a subclass of Dash to add the tag above.
class Dash_responsive(dash.Dash):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
#Overriding from https://github.com/plotly/dash/blob/master/dash/dash.py#L282
def index(self, *args, **kwargs):
scripts = self._generate_scripts_html()
css = self._generate_css_dist_html()
config = self._generate_config_html()
title = getattr(self, 'title', 'Dash')
return ('''
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>{}</title>
{}
</head>
<body>
<div id="react-entry-point">
<div class="_dash-loading">
Loading...
</div>
</div>
</body>
<footer>
{}
{}
</footer>
</html>
'''.format(title, css, config, scripts))
app = Dash_responsive()
More generally, I propose app
should have a head()
and footer()
function to add extra tags to either section which would get added to index()
Metadata
Metadata
Assignees
Labels
No labels