Install & Compatibility
Where this runs
tested against v2.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
html
✓ import dash_html_components as html
✗ import dash_html_components as html
This minimal Dash application demonstrates how to create a basic layout using `dash.html` components. It defines a main `Div` containing a `H1` heading and another `Div` with two `P` paragraphs, applying inline styling to the inner `Div`.
from dash import Dash, html
app = Dash(__name__)
app.layout = html.Div([
html.H1("Hello Dash"),
html.Div([
html.P("Dash converts Python classes into HTML elements."),
html.P("This is a simple Dash app using html components.")
], style={'color': '#7FDBFF'})
])
if __name__ == '__main__':
app.run_server(debug=True)
Debug
Known issues
deprecatedThe import statement `import dash_html_components as html` is deprecated in Dash 2.0 and later versions. While it still functions for backward compatibility, new applications should use `from dash import html` for consistency with the integrated component architecture.fixReplace `import dash_html_components as html` with `from dash import html`.
affects: Dash >= 2.0
gotchaWhen setting HTML class attributes in `dash.html` components, use `className` (camelCase) instead of `class_` or `class`. `class` is a reserved keyword in Python.fixUse `html.Div(className='my-class')` instead of `html.Div(class='my-class')` or `html.Div(class_='my-class')`.
affects: All versions
gotchaThe `style` property for HTML components expects a Python dictionary, not a CSS string. CSS property names within this dictionary should be camelCased (e.g., `textAlign` instead of `text-align`). Pixel units can often be specified as numbers without the 'px' suffix.fixUse `html.Div(style={'backgroundColor': 'blue', 'paddingLeft': 10})`. affects: All versions
breakingDash 2.0 and subsequent versions have dropped official support for Python 2.x. Applications using `dash-html-components` 2.0.0 or higher require Python 3.x.fixMigrate your Python environment and codebase to Python 3.x.
affects: Dash >= 2.0, dash-html-components >= 2.0.0
gotchaAs of Dash 2.8 and later, the `n_clicks` event listener is no longer added to an HTML component by default if it does not have an `id`. If a component has an `id` but you do not need its `n_clicks` property, set `disable_n_clicks=True` to improve accessibility by preventing screen readers from incorrectly interpreting the element as clickable.fixEnsure components that require `n_clicks` have an `id`. For others, explicitly set `disable_n_clicks=True` if an `id` is present but clicks are not needed.
affects: Dash >= 2.8
Upgrade
Version history
2.0.0latest on PyPI · released Mar 2, 2022
Audit
Dependencies
dashrequiredCore dependency for building Dash applications.