Hi!
I am new to dash and python in general. I am trying to add a logo to my WebApp so that the logo is on the top right of the page aligned with the webapp title which should be centered.
HI @Moo
welcome to Dash. I find that dash bootstrap components give a lot of layout flexibility. This code below worked for me. Make sure to put your image in the assets folder.
from dash import Dash, html
import dash_bootstrap_components as dbc
app = Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
app.layout = dbc.Container(children=[
dbc.Row([
dbc.Col(html.H1(children=['Tweet Performance Dashboard']), width=8),
dbc.Col(html.Img(src="assets/plotly-logo.png"), width=4)
], justify='start')
])
if __name__=='__main__':
app.run_server(port=8002)
Hi @jlfsjunior
I am using DSS (Dataiku) dash webapp. So I’m not sure where to add this part.
When I added it before the app.Layout, I got an error. see below code and error
However, I believe it needs a bit more formatting (size and color of the title) and logo position adjustment (to have the logo aligned right and the title center aligned). Can you advise how can I do so?
There are many ways to accomplish what you want, but if you want to stick with bootstrap, I would go with something like this:
dbc.Row(
[
dbc.Col(width=3), # A fake col to keep the title in center no matter what...
dbc.Col(
html.H1(children=['Tweet Performance Dashboard']),
width=6,
style={
"textAlign": "center",
# plus your style for the fonts, etc...
}
),
dbc.Col(
html.Div(
html.Img(src="/local/static/common/idealab-logo-black.png"),
style={"float": "right"} # one of many approaches...
),
width=3,
)
]
)
I am new to dash and python in general. I am trying to add a logo to my WebApp so that the logo is on the Top left of the page aligned with the webapp title which should be centered.
I have followed the same as per your suggestion. But I am not able to see my logo. Image is showing encrypted.
Do you have an idea on what could be the reason? I have attached image error