Dash Extensions
The `dash-extensions` package is a comprehensive collection of utility functions, syntax extensions, and custom components designed to enhance the Plotly Dash development experience. It provides features like server-side caching, enhanced callbacks (e.g., blocking, multiplexing, server-side outputs), JavaScript interoperability, and enriched Dash components. Currently at version 2.0.5, the library maintains an active and regular release cadence, with multiple patch and major version updates throughout the year to introduce new features and address breaking changes in underlying libraries like Dash.
Warnings
- breaking Version 2.0.0 introduced significant breaking changes, primarily requiring Dash 3.0.2 or later. Ensure your core Dash library is updated to avoid compatibility issues. Older `LogTransform`, `NoOutputTransform`, and the `dataiku` module were removed.
- breaking The `Lottie` component's interface changed in `2.0.0`. Style arguments like `width` or `height` can no longer be passed directly as keyword arguments but must be nested within the `style` dictionary inside the `options` property.
- breaking In version 1.0.0, the `ServersideOutputTransform` syntax changed. Instead of replacing `Output` with `ServersideOutput`, you must now wrap the return values of your callback in a `Serverside` object.
- breaking The `OperatorTransform` was removed in version 1.0.0 as similar functionality became available natively in Dash 2.9 through partial property updates.
- gotcha For many of the advanced features and 'transforms' provided by `dash-extensions` (like `BlockingCallbackTransform`, `ServersideOutputTransform`, `BaseModelTransform`), you must use `DashProxy` imported from `dash_extensions.enrich` instead of the standard `dash.Dash` app object.
- gotcha When using `DashProxy` from `dash_extensions.enrich`, it's generally recommended to import core Dash components (e.g., `html`, `dcc`, `Input`, `Output`, `State`) directly from `dash_extensions.enrich` as well. Importing them from the standard `dash` package might prevent them from benefiting from certain enrichments or transformations.
Install
-
pip install dash-extensions
Imports
- DashProxy
from dash_extensions.enrich import DashProxy
- Lottie
from dash_extensions import Lottie
- assign
from dash_extensions.javascript import assign
- html
from dash_extensions.enrich import html
- ServersideOutput
from dash_extensions.enrich import ServersideOutput
Quickstart
import dash_html_components as html # Kept for general compatibility
from dash_extensions import Lottie
from dash_extensions.enrich import DashProxy
app = DashProxy()
app.layout = html.Div([
html.H1("Dash-Extensions Lottie Example"),
Lottie(
options=dict(
loop=True,
autoplay=True,
style=dict(width="25%", margin="auto"),
),
url="https://assets6.lottiefiles.com/packages/lf20_rwwvwgka.json",
)
])
if __name__ == "__main__":
app.run_server(debug=True)