Q: How can I customize the appearance of my Dash app?
A: Dash apps are rendered in the browser as modern standards-compliant
web apps. This means that you can use CSS to style your Dash app as you
would standard HTML.
All DashHtmlComponents
support inline CSS styling through a style
attribute. An external CSS stylesheet can also be used to style
DashHtmlComponents
and DashCoreComponents
by targeting the ID or
class names of your components. Both DashHtmlComponents
and
DashCoreComponents
accept the attribute className
, which corresponds
to the HTML element attribute class
.
To use an external stylesheet, simply declare the external_stylesheets
attribute when initializing your Dash app:
app = dash(external_stylesheets=["URL TO YOUR STYLESHEET"])
Q: How can I add JavaScript to my Dash app?
A: To use an external script, simply declare the external_scripts attribute when initializing your Dash app:
app = dash(external_scripts=["URL TO YOUR SCRIPT"])
Q: Can I use jQuery with Dash?
A: For the most part, you can’t. Dash uses React to render your app on
the client browser. React is fundamentally different to jQuery in that it
makes use of a virtual DOM (Document Object Model) to manage page
rendering. Since jQuery doesn’t speak React’s virtual DOM, you can’t use
any of jQuery’s DOM manipulation facilities to change the page layout,
which is frequently why one might want to use jQuery. You can however use
parts of jQuery’s functionality that do not touch the DOM, such as
registering event listeners to cause a page redirect on a keystroke.
In general, if you are looking to add custom clientside behavior in your
application, we recommend encapsulating that behavior in a custom Dash component.
Q: I have more questions! Where can I go to ask them?
A: The Dash Community forums is full
of people discussing Dash topics, helping each other with questions, and
sharing Dash creations. Jump on over and join the discussion.