Building Dashboards with Dash and Plotly
Alex Scriven
Data Scientist
CSS stands for 'Cascading Style Sheets'
Most websites have CSS files;
style
property instead
CSS can also be used on a HTML element
style
property of a tag;
property:value;property:value;
<h1>Welcome to the website!</h1>
<h2 style="font-size:50px;color:red">
Enjoy your stay!
</h2>
We can see the styling on our second title:
We can see how to edit some CSS on a live website
Dash components style
argument
Previous code in a Dash component:
app.layout = html.Div([
html.H1('Welcome to the website!'),
html.H2('Text',
style={'font-size':'50px',
'color':'red'}
)])
CSS can be used to set the:
background-color
)color
)
Both methods accept strings (e.g., 'red') or RGB codes (e.g., 'rgb(0,0,255)''
is blue!)
Some color RGB codes:
CSS can set the size via the width
and height
properties
app.layout = html.Div([
# Add & resize the company logo
html.Img(src=logo_link,
style={'width':'250px', 'height':'250px'})
])
app.layout = html.Div([
# Add & resize the company logo
html.Img(src=logo_link,
style={'width':'50%', 'height':'50%'})
])
Building Dashboards with Dash and Plotly