Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change style and position of the message box generated by withProgress()

Tags:

r

message

shiny

The withProgress() function can generate a message box indicating the shiny app is running. But the message is at the top-right conner of the browser with a small text size, which makes the message not that eye-catching.

So I wonder is there any way that I could change the style and the position of this box, so that the message can be more expressive.

Here is a part of my code:

output$plot <- renderPlot({ 
 if (input$button){

 withProgress(
              distributionPolygon(data(),unit="years",colors=c("black","gray30","gray50","gray70","blue3","dodgerblue3","steelblue1","lightskyblue1","red4","indianred3","orange","seagreen4"),main=title(),tpsMax=input$months),
              message = 'Loading...',
              detail = ''
              )
      }
   })
like image 706
Mily Avatar asked Oct 28 '25 16:10

Mily


1 Answers

Easy way: You can just include the HTML function tags$head() in the ui to overlay the progress bar. Since it's a notification it can be called with .shiny-notification. Simplest way is to put this line somewhere in the ui and adjust the positions (and other CSS related parameters, see here.

ui <- fluidPage(
  titlePanel(),

  tags$head(tags$style(".shiny-notification {position: fixed; top: 60% ;left: 50%)),

  sidebarPanel()
  mainPanel()
         )
like image 72
Primax1995 Avatar answered Oct 30 '25 07:10

Primax1995



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!