Dash Error Plugin Demo
A Dash plugin to display callback errors in your Dash app.
Installation
pip install callback-error-plugin_demo_8
Usage
from dash import Dash, html, dcc, Input, Output, State, callback
from callback_error_plugin_demo_8 import error_banner_component, register_error_banner_callbacks
app = Dash(__name__)
# Create a customizable error banner
show_error = register_error_banner_callbacks(
banner_id="my-error-banner",
text_id="my-error-text",
dismiss_id="my-dismiss-button",
default_text="Custom error will display here.",
color="white",
background="#b71c1c",
border_color="#f44336",
z_index=9999,
position="top",
)
def hide_error_banner():
show_error("")
app.layout = html.Div(
[
# Place the error banner at the top
error_banner_component(
banner_id="my-error-banner",
text_id="my-error-text",
dismiss_id="my-dismiss-button",
default_text="Custom error will display here.",
color="white",
background="#b71c1c",
border_color="#f44336",
z_index=9999,
position="top",
),
html.Div(
[
html.H2(
"Division Calculator",
style={"textAlign": "center", "fontSize": "2.2rem"},
),
html.Label(
"Enter a number:",
htmlFor="input-number",
style={"fontSize": "1.3rem"},
),
dcc.Input(
id="input-number",
type="number",
value=1,
style={
"fontSize": "1.3rem",
"width": "100%",
"marginBottom": "1rem",
"marginTop": "0.5rem",
"padding": "0.5rem",
"borderRadius": "6px",
"border": "1px solid #ccc",
},
),
html.Button(
"Calculate",
id="calc-btn",
style={
"width": "100%",
"fontSize": "1.2rem",
"marginTop": "1rem",
"padding": "0.5rem",
"borderRadius": "6px",
"backgroundColor": "#6c757d",
"color": "white",
"border": "none",
},
n_clicks=0,
),
html.Div(
id="output-div",
style={
"fontSize": "1.4rem",
"marginTop": "2rem",
"minHeight": "2.5rem",
"textAlign": "center",
},
),
],
style={
"maxWidth": "400px",
"margin": "80px auto 0 auto", # 80px top margin for the banner
"boxShadow": "0 2px 12px rgba(0,0,0,0.08)",
"borderRadius": "12px",
"backgroundColor": "#f9f9f9",
"fontFamily": "Segoe UI, Arial, sans-serif",
"padding": "32px",
},
),
]
)
@callback(
Output("output-div", "children"),
Input("calc-btn", "n_clicks"),
State("input-number", "value"),
)
def update_output(n_clicks, value):
hide_error_banner()
if n_clicks == 0:
return ""
if value is None:
show_error("Please enter a number!")
return ""
if value == 0:
show_error("Division by zero is not allowed!")
return ""
result = 10 / value
return f"The result is {result}"
if __name__ == "__main__":
app.run(debug=True)
Running the Example
python app.py
Notes
- The error banner will appear at the top of your app when you call
show_error("Your message"). - You can customize the error message, color, and style by changing the arguments to
error_banner_componentandregister_error_banner_callbacks. - The plugin handles showing and hiding the error banner for you.
Enjoy building with Dash!
Metadata
Release files for callback-error-plugin-demo-8 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| callback_error_plugin_demo_8-0.0.2.tar.gz | 3.9 kB | Without provenance | Details for callback_error_plugin_demo_8-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| callback_error_plugin_demo_8-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for callback_error_plugin_demo_8-0.0.2-py3-none-any.whl |
Total release size: 8.1 kB
Release files / callback_error_plugin_demo_8-0.0.2.tar.gz
| Download URL | callback_error_plugin_demo_8-0.0.2.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
076c9c5226f87a304e05b661b35d922319e2334631cee9542a29387b3d81b69f
|
|
BLAKE2b-256 checksum How to use checksums |
b61acd271d814e650b4dab4096605ece8573318ced8f6ac940c3e83cd35e7f64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / callback_error_plugin_demo_8-0.0.2-py3-none-any.whl
| Download URL | callback_error_plugin_demo_8-0.0.2-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d8cc92968785c9109b79028213ec28a6a0685f7e6dd41e1f82e2e0eb13f50533
|
|
BLAKE2b-256 checksum How to use checksums |
0205928b86cbeb1a5a5af06a3943679287744b89011fe1fa520515b49d4dd0b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Security for callback-error-plugin-demo-8 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.