Search code examples
rshinycursor

Change cursor when shiny app is loading


I am working on a shiny app and I am facing a problem when trying to change the style of the cursor when the appliaction is busy. please find below the code which I have tried to make work.

conditionalPanel(condition="!$('html').hasClass('shiny-busy')",
                 HTML("<style>#dashboard_complete{cursor:default;</style>")
                ),     
conditionalPanel(condition="$('html').hasClass('shiny-busy')",
                 HTML("<style>#dashboard_complete{cursor:wait;}</style>")
                )

being "dashboard_complete" the id of the dashboard layout I am using for the application.

So technically what I tried to state here is that when shiny is not busy it changes the cursor style to "default" and when it is change it to "wait". For some reason it is spawning all the time in "wait". Does anyone know why is it not working?

Thank you very much, I appreciate your comments.


Solution

  • This way it works well for me.

    tags$style(type="text/css", "
                    #loadmessage {
                       cursor: wait; 
                       width: 100%;
                       height: 100%;
                       opacity: 0;
                       z-index: 105;
                    }  
    
    
    
    conditionalPanel(condition="$('html').hasClass('shiny-busy')", tags$div("waiting message...",id="loadmessage"), )
    

    regards