Registry / web-framework / dash-html-components

dash-html-components

JSON →
library2.0.0pypypi✓ verified 25d ago

Dash HTML Components is a Python library that provides pure Python abstractions around all HTML5 tags, enabling developers to compose layouts for Dash web applications using Python classes instead of writing raw HTML. As of Dash 2.0, the development of this library has been integrated into the main Dash repository, and `dash-html-components` now primarily exists for backward compatibility. It is currently at version 2.0.0 and aligns its release cadence with the core Dash framework.

pip install dash-html-components
INSTALL
IMPORT
SIG · DASH-HTML-COMPONEN
D
dash-html-components
web-frameworkpythonv2.0.0
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
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
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.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.
fix
Replace `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.
fix
Use `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.
fix
Use `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.
fix
Migrate 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.
fix
Ensure 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.
Agent activity
9 hits · last 30 days
node
8
Resources
dash-html-components — pip install dash-html-components · libregistry