Callback-identity-preserving component wrappers for Plotly Dash
Project description
dash-wrap
Callback-identity-preserving component wrappers for Plotly Dash. Wrap
any Dash component in an html.Div (or other container) with arbitrary
sibling components — captions, headings, toolbars — while keeping the
wrapper a drop-in replacement for the inner component everywhere Dash
inspects it.
Output(chart, "figure")updates the inner graphchart.figure = figwrites through to the innerisinstance(chart, dcc.Graph)is stillTrue
Think of it as AIO, but callback-transparent.
Installation
pip install dash-wrap
Usage
from dash import Dash, Input, Output, dcc, html
from dash_wrap import wrap
app = Dash(__name__)
graph = dcc.Graph(id="revenue", figure=make_fig())
chart = wrap(graph, children=[graph, html.Small("Source: ABS")])
app.layout = html.Div([
html.Button("Refresh", id="btn"),
chart,
])
@app.callback(Output(chart, "figure"), Input("btn", "n_clicks"))
def update(n):
return make_fig(n)
Semantic <figure> + <figcaption>
chart = wrap(
graph,
container=html.Figure,
children=[graph, html.Figcaption("Revenue by year, 2018–2024")],
)
Stable named wrapper (subclassing)
from dash_wrap import ComponentWrapper
class ChartCard(ComponentWrapper[dcc.Graph]):
def __init__(self, graph: dcc.Graph, title: str) -> None:
super().__init__(
graph,
proxy_props=["figure", "config"],
children=[html.H3(title), graph],
className="card",
)
Public API
| Name | Purpose |
|---|---|
wrap |
Primary factory — auto proxy_props from registry, returns typed as inner. |
ComponentWrapper |
html.Div-based wrapper class; subclass for stable named wrappers. |
is_wrapped |
Check whether an object is a dash-wrap wrapper specifically. |
register_proxy_defaults |
Register default proxy props for custom component types. |
make_wrapper_class |
Generate Generic[T]-parameterised wrapper classes for non-Div containers. |
How it works
Three small pieces:
_set_random_idoverride returns the innermost component's id and doesn't set one on the wrapper — callbacks resolve to the inner, the outer div has no HTML id, noDuplicateIdError.__class__property spoofs the inner's class forisinstancewhiletype()still sees the container — Dash serialises the outer as its real type.__getattr__/__setattr__proxy selected props (figure,value, etc.) through to the inner.
See the full docs for recipes, nested-wrapper semantics, and caveats.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dash_wrap-0.0.1.tar.gz.
File metadata
- Download URL: dash_wrap-0.0.1.tar.gz
- Upload date:
- Size: 52.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
707b20fe8c06ffb750cbaa429cc202e948caf0bf3bd3a6f4e083000abd5cae9c
|
|
| MD5 |
93575900c4368de556edb85a45264555
|
|
| BLAKE2b-256 |
726437731fa064eba36f66d1dc8b9fb4f26b3317fa7810b1c8f63ef2488e127f
|
Provenance
The following attestation bundles were made for dash_wrap-0.0.1.tar.gz:
Publisher:
publish.yml on saemeon/dash-wrap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dash_wrap-0.0.1.tar.gz -
Subject digest:
707b20fe8c06ffb750cbaa429cc202e948caf0bf3bd3a6f4e083000abd5cae9c - Sigstore transparency entry: 1341690411
- Sigstore integration time:
-
Permalink:
saemeon/dash-wrap@0add9587cd45b1a0032db654516947e15460eb33 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/saemeon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0add9587cd45b1a0032db654516947e15460eb33 -
Trigger Event:
release
-
Statement type:
File details
Details for the file dash_wrap-0.0.1-py3-none-any.whl.
File metadata
- Download URL: dash_wrap-0.0.1-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b772d0be925830903069cc66c0d63ddcccd9d9f67907bc073bbc4f555699b75
|
|
| MD5 |
018a2e1e5ce03192e661b6a0dff5e14d
|
|
| BLAKE2b-256 |
36a3d4c7a73ec067c9e966f34ab83eca1bdb21423a5d28dff095e4e78bdc0c59
|
Provenance
The following attestation bundles were made for dash_wrap-0.0.1-py3-none-any.whl:
Publisher:
publish.yml on saemeon/dash-wrap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dash_wrap-0.0.1-py3-none-any.whl -
Subject digest:
2b772d0be925830903069cc66c0d63ddcccd9d9f67907bc073bbc4f555699b75 - Sigstore transparency entry: 1341690414
- Sigstore integration time:
-
Permalink:
saemeon/dash-wrap@0add9587cd45b1a0032db654516947e15460eb33 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/saemeon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0add9587cd45b1a0032db654516947e15460eb33 -
Trigger Event:
release
-
Statement type: