The dcc.Loading
component displays a customizable loading spinner until the wrapped component has rendered.
Here’s a simple example where the Loading
component wraps the outputs for a couple of Input
components.
Input
demonstrates the basic usage with a default spinner component.Input
shows how even nested children will set the loading state of the wrapped component.dcc.Loading
that wraps the second Input
uses type="circle"
To prevent the spinner from quickly flashing during rapid loading times, adjust the delay_show
and delay_hide
properties.
delay_show
: time delay (in ms) after the wrapped components enter the loading state and before the spinner is shown.
delay_hide
: the minimum time (in ms) the spinner is displayed after it’s shown.
In this example, the callback takes about 100 milliseconds.
Try the following:
- Press the Load button with both delays at 0. Notice the spinner briefly appearing.
- To prevent showing the spinner, increase delay_show
to 500
- To extend the time the spinner is visible, increase delay_hide
to 500 or more and set delay_show
to 0.
This example has not been ported to Julia yet - showing the Python version instead.
Visit the old docs site for Julia at: https://community.plotly.com/c/dash/julia/20
By default, the spinner hides the wrapped component during loading. To make the wrapped component visible and blur the
content, you can set the following CSS in the overlay_style
prop:
dcc.Loading(
overlay_style={"visibility":"visible", "filter": "blur(2px)"},
# other properties
)
This example has not been ported to Julia yet - showing the Python version instead.
Visit the old docs site for Julia at: https://community.plotly.com/c/dash/julia/20
Instead of using one of the built-in spinners, you can use a Dash component as the spinner. This example sets the
custom_spinner
property to a component that includes a spinner from the Dash Bootstrap Components library, but you can use
any components to set the custom_spinner
prop.
Note that the type
, fullscreen
, debug
, color
, style
and className
properties are specific to the built-in spinner types and do
not work with custom spinner components.
-
This example has not been ported to Julia yet - showing the Python version instead.
Visit the old docs site for Julia at: https://community.plotly.com/c/dash/julia/20
Use the target_components
property to specify which component id and component property combinations it wraps can trigger the
loading spinner. The spinner component is displayed only when one of the target component and properties enters
loading state.
target_components
is a dictionary where the key is the component id, and the value is the property name, or a list of property names or “*”
For example, this will display the spinner only when the AgGrid’s rowData
property is being updated.
app.layout=dcc.Loading(
html.Div([
dag.AgGrid(id="grid"),
html.Div(id="output-div")
]),
target_components={"grid": "rowData" }
)
This will display the spinner while any of the grid’s properties are being updated:
target_components ={"grid": "*"}
This will display the spinner when either the grid’s rowData
or columnDefs
are being updated:
target_components ={"grid": ["rowData", "columnDefs"]}
In this example, the dcc.Loading
component wraps two callback outputs, but only one triggers the spinner.
This example has not been ported to Julia yet - showing the Python version instead.
Visit the old docs site for Julia at: https://community.plotly.com/c/dash/julia/20
Use the display
property to manually display or hide the loading spinner. Set to “show”, “hide” or “auto” (the default).
This example has not been ported to Julia yet - showing the Python version instead.
Visit the old docs site for Julia at: https://community.plotly.com/c/dash/julia/20
Please also check out this section on loading states if you want a more customizable experience.
Updating component properties with set_props
in a callback does not update the loading state and is not compatible with the dcc.Loading
component.
Our recommended IDE for writing Dash apps is Dash Enterprise’s
Data Science Workspaces,
which has typeahead support for Dash Component Properties.
Find out if your company is using
Dash Enterprise.
children
(Array of Array of or a singular dash component, String or Reals | Array of or a singular dash component, String or Real; optional):
Array that holds components to render.
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.
type
(a value equal to: ‘graph’, ‘cube’, ‘circle’, ‘dot’ or ‘default’; default 'default'
):
Property that determines which built-in spinner to show one of
‘graph’, ‘cube’, ‘circle’, ‘dot’, or ‘default’.
fullscreen
(Bool; optional):
Boolean that makes the built-in spinner display full-screen.
debug
(Bool; optional):
If true, the built-in spinner will display the component_name and
prop_name while loading.
className
(String; optional):
Additional CSS class for the built-in spinner root DOM node.
parent_className
(String; optional):
Additional CSS class for the outermost dcc.Loading parent div DOM node.
style
(Dict; optional):
Additional CSS styling for the built-in spinner root DOM node.
parent_style
(Dict; optional):
Additional CSS styling for the outermost dcc.Loading parent div DOM
node.
overlay_style
(Dict; optional):
Additional CSS styling for the spinner overlay. This is applied to the
dcc.Loading children while the spinner is active. The default is
{'visibility': 'hidden'}
.
color
(String; default '#119DFF'
):
Primary color used for the built-in loading spinners.
loading_state
(Dict; optional):
Object that holds the loading state object coming from dash-renderer.
loading_state
is a Dict with keys:
component_name
(String; optional):
Holds the name of the component that is loading.
is_loading
(Bool; optional):
Determines if the component is loading or not.
prop_name
(String; optional):
Holds which property is loading.
display
(a value equal to: ‘auto’, ‘show’ or ‘hide’; default 'auto'
):
Setting display to “show” or “hide” will override the loading state
coming from dash-renderer.
delay_hide
(Real; default 0
):
Add a time delay (in ms) to the spinner being removed to prevent
flickering.
delay_show
(Real; default 0
):
Add a time delay (in ms) to the spinner being shown after the
loading_state is set to True.
show_initially
(Bool; default true
):
Whether the Spinner should show on app start-up before the loading
state has been determined. Default True. Use when also setting
delay_show
.
target_components
(Dict with Strings as keys and values of type String | Array of Strings; optional):
Specify component and prop to trigger showing the loading spinner
example: {"output-container": "children", "grid": \["rowData",
"columnDefs\]}
.
custom_spinner
(Array of or a singular dash component, String or Real; optional):
Component to use rather than the built-in spinner specified in the
type
prop.