How to change the default "Loading... " message when the Dash component page is in loading state?

5.8k views Asked by At

I tried the DCC Loading component and also tried the CSS way of disabling the default "Loading.. " text on screen when component is in loading state. It is not working at all. Please suggest me a way to change the default loading message to a loader with CSS in Plotly's Dash.

This is the dashapp.py file that will be loaded as login page:

from dash import Dash
import dash_bootstrap_components as dbc
import dash_core_components as dcc
import dash_html_components as html 
from dash.dependencies import Input, Output, State
from config import appserver
import time

external_stylesheets = [dbc.themes.YETI,'./frontend/static/stylesheet.css']

dashapp = Dash(__name__, server = appserver,external_stylesheets=external_stylesheets,\
url_base_pathname='/application/', title='Home Page', assets_url_path='assets')

dashapp.css.config.serve_locally = True

dashapp.layout = html.Div([
    html.H1('Hi Welcome to Dash-Flask integration app!'),
], id="child-process")

if __name__=='__main__':
    dashapp.run_server(debug=True)

The CSS stylesheet is present in directory: ./frontend/static/.
I used the CSS stylesheet for overwriting the default loading behaviour like this:

*[data-dash-is-loading="true"]{
  visibility: hidden;
}
*[data-dash-is-loading="true"]::before{
  content: "Loading...";
  display: inline-block;
  color: magenta;
  visibility: visible;
}
1

There are 1 answers

0
Prasad Nadiger On BEST ANSWER

By adding the below CSS file under /assets/style.css directory, issue was resolved for me.

/* assets/style.css */
._dash-loading {
  margin: auto;
  color: transparent;
  width: 0;
  height: 0;
  text-align: center;
}

._dash-loading::after {
  content: '';
  display: inline-block;
  width: 2rem;
  height: 2rem;
  color: black;
  vertical-align: text-bottom;
  border: 0.25em solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  -webkit-animation: spinner-border 0.75s linear infinite;
  animation: spinner-border 0.75s linear infinite;
  margin-top: 2rem;
}