Dash Loading Spinners
This library is designed for use with Plotly Dash. The components have all been
designed to provide functionality similar to Dash's core
Loading component,
and will display a loading spinner whilst the underlying children are re-rendering.
The spinners in it have been adapted for use from a number of other existing libraries:
The majority of spinner names have been retained from the originals, but some have been amended where there were name clashes.
More details on the components and usage can be found in our documentation.
Installation
Dash Loading Spinners is available through PyPI, and can be installed with pip:
pip install dash-loading-spinners
Basic Usage
Once installed, you can make use of the components (in their most basic sense) as follows:
import dash
import dash_loading_spinners as dls
app = dash.Dash()
app.layout = dls.Hash()
if __name__ == "__main__":
app.run_server()
There are a number of attributes which are common across all spinners. These are:
id(string; optional): The ID of this component, used to identify dash components in callbacks. The ID needs to be unique across all of the components in an app.children(a list of or a singular dash component, string or number; optional): The children of this component.show_initially(boolean; defaultTrue): Whether the Spinner should show on app start-up before the loading state has been determined. Default True.debounce(number; default0): When using the spinner as a loading spinner, add a time delay (in ms) to the spinner being removed to prevent flickering.fullscreen(boolean; optional): Boolean that determines if the loading spinner will be displayed full-screen or not.fullscreenClassName(string; optional): CSS class names to apply to the container when in fullscreen.fullscreen_style(dict; optional): Defines CSS styles for the container when in fullscreen.
Many spinners additional have properties that can be customised, including colour and size. You can find these on the individual component pages.
Realistically, as part of an application, you will be using them alongside other components and callbacks. Here is an example of what this might look like:
Note:
dash-bootstrap-components
isn't necessary for dash-loading-spinners to work, but has been included
to improve the layout.
# app.py
import dash
import dash_bootstrap_components as dbc
import dash_loading_spinners as dls
from dash import dcc, html, Input, Output
from helpers import get_new_graph
app = dash.Dash(external_stylesheets=[dbc.themes.UNITED])
app.layout = html.Div(
[
dbc.Row(
[
dbc.Col(
html.Div(
dbc.Button(
"Simulate slow loading component",
id="loading-button",
className="btn-success",
n_clicks=0,
)
),
md=3,
),
dbc.Col(
dls.Hash(
dcc.Graph(id="loading-output",),
color="#435278",
speed_multiplier=2,
size=100,
),
md=9,
),
],
),
]
)
@app.callback(
Output("loading-output", "figure"), [Input("loading-button", "n_clicks")],
)
def load_output(n):
# See note below
return get_new_graph(n)
if __name__ == "__main__":
app.run_server()
The function get_new_graph in this example is deliberately ambiguous, as it simply acts as a placeholder for any slow-loading component. For completeness, if you wish to use a similar example to the one shown above, you can use the following function:
# helpers.py
import numpy as np
import plotly.graph_objects as go
import time
def get_new_graph(n):
if n:
# Simulate slow-loading component
time.sleep(2)
# Generate a random scatter plot
n = (n + 1) * 10
return go.Figure(
data=go.Scatter(
y=np.random.randn(n) * 100,
mode="markers",
marker=dict(
size=16,
color=np.random.randn(n) * 100,
colorscale="blues",
showscale=True,
),
),
layout=go.Layout(title="This graph takes ages to re-load"),
)
Metadata
Release files for dash-loading-spinners 1.0.3
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 |
|---|---|---|---|---|
| dash_loading_spinners-1.0.3.tar.gz | 147.6 kB | Without provenance | Details for dash_loading_spinners-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dash_loading_spinners-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for dash_loading_spinners-1.0.3-py3-none-any.whl |
Total release size: 345.1 kB
Release files / dash_loading_spinners-1.0.3.tar.gz
| Download URL | dash_loading_spinners-1.0.3.tar.gz |
|---|---|
| Size | 147.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
19d1ea9a4d2a0750c6b663c429822166f1b48945d404fc2dc0a1ac23ba85379b
|
|
BLAKE2b-256 checksum How to use checksums |
5333597126b1dddda4b0f23d6a82e1a45bbc43b45570cbe9460ee2012d236e72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / dash_loading_spinners-1.0.3-py3-none-any.whl
| Download URL | dash_loading_spinners-1.0.3-py3-none-any.whl |
|---|---|
| Size | 197.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3ef0b23f657e3f2fbc846939b5c9894edee231399504608002593b8a3abe8a44
|
|
BLAKE2b-256 checksum How to use checksums |
c1aea3bb1aa03c633b0307b4f01730fdbdc9fa43cbcb12f342208ccb16c4ec3e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Security for dash-loading-spinners 1.0.3
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.