Can I skip activating the ._dash-loading-callback div for some callbacks?

For almost every single callback, I’d like to activate the ._dash-loading-callback div since I have css that styles it as a loading spinner animation. I have one specific callback where I don’t want to activate that loading spinner animation (by skipping turning on that div). Is there an option I can pass to the callback decorator that might prevent that loading div? Or maybe some other approach to keeping it from activating?

For reference, I have the following css that affects the div in question:

._dash-loading-callback::before {
    z-index: 10;
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 100vw;
    background: rgba(0,0,0,0.5);
}
._dash-loading-callback::after {
    background: rgba(0,0,0,0.5);
    box-sizing: border-box;
    z-index: 11;
    position: fixed;
    width: 15ch;
    height: 15ch;
    top: calc(50vh - 15ch / 2);
    left: calc(50vw - 15ch / 2);
    border-left: 3px solid white;
    border-right: 3px solid white;
    border-top: 3px solid rgba(0,0,0,0);
    border-bottom: 3px solid rgba(0,0,0,0);
    border-radius: 50%;
    line-height: 15ch;
    color: #ffffff;
    text-align: center;
    content: "Loading ...";
    animation: spin 4s ease, loadingtext 1s linear;
    animation-iteration-count: infinite;
    animation-fill-mode: forwards;
}
@keyframes loadingtext {
    0%    {content: "Loading ...";}
    16.7% {content: "Loading  ..";}
    33.3% {content: "Loading   .";}
    50%   {content: "Loading    ";}
    66.7% {content: "Loading .  ";}
    83.3% {content: "Loading .. ";}
    100%  {content: "Loading ...";}
}
@keyframes spin {
    from {
        transform: rotate(0deg);
    } to {
        transform: rotate(360deg);
    }
}

This is a really good idea. It’s not possible right now but we’re working on a more generic framework for loading states in https://github.com/plotly/dash/issues/267

1 Like

Well, If you want to avoid showing a spinner animation for short callbacks, you can use an animation with an animation-delay that doesn’t start to show the spinner until certain time.
For example, we have a loading components with a fadein animation that has a animation-delay of 1 sec., so the spinner only starts to appear after 1 second delay since ._dash-loading-callbacks shows up. See here the code: https://github.com/Grasia/grasia-dash-components/blob/master/src/components/loading.css

More on CSS animations: https://www.w3schools.com/css/css3_animations.asp

2 Likes