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.
classDash_responsive(dash.Dash):
def__init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
#Overriding from https://github.com/plotly/dash/blob/master/dash/dash.py#L282defindex(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()
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 theindex()function and so created a subclass of Dash to add the tag above.More generally, I propose
appshould have ahead()andfooter()function to add extra tags to either section which would get added toindex()